I’m using this /\([^\S\n]*(.*)[^\S\n]*\)/ regex to match what is inside brackets, and it works good except when there are trailing spaces, it matches them.
In for example ( test1 test2 ) I would like to match test1 test2, but I match test1 test2_ (I wrote underscore, but it’s trailing space).
Any idea how to remove this trailing space from my match?
I’m using PHP preg_replace function.
Try this
Result: