Answer the question
In order to leave comments, you need to log in
How to remove all characters in a string except characters in brackets (preg_replace)?
How to remove all characters in a string except characters in brackets
example
ylne(_4043() wapdsff) rtnbe' => _4043() wapdsff I
thought to replace the first half to the character "(" and then starting from the extreme "(" and to the end only xs like or everything is possible in one regular expression (I don’t understand regular expressions well)
Answer the question
In order to leave comments, you need to log in
If you don’t get fancy with nesting, then you need to find any number of any characters a character between brackets: (.+)
and just pull them out. So that the brackets do not fall into the selection - apply backward looking (at the first bracket) and looking forward (at the last one): (?<=\().+(?=\))
Demo: https://regex101.com/r/XBrb9s/1
Wikipedia has a very useful article about regular expressions, I recommend : //ru.wikipedia.org/wiki/Regular_expressions...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question