php - Extract whatever is in brackets using regular expressions -


I really do not understand regex, and it hurts my head.

I

  blah blah blah (here i want to remove anything)   

... and I do not have PHP preg_split , Or equivalent, using the command, how to remove it, does not really understand.

How can I do this? And where is a good place to understand how it works?

Something like this should do the trick, ( and ) What is the :

  $ str = "blah blah blah (here i want to take a little away)"; If (preg_match ('/ \ (([^ \)] +) \' / ', $ str, $ matches) {var_dump ($ matches [1]); }   

and you will get:

  string 'Here is the bit that I want to remove' (length = 35)   


Actually, the method I used to search for:

  • An opening (; But as it does (special meaning, this To avoid: \ (
  • One or more characters that are not closing brackets: [^ \)] +
    • It is being captured, so we can use it later: ([^ \)] +)
    • And this is the first (and
    • A termination ) $ matches [1] > As available; Even here, it is a special character to save: \)

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -