I would suggest something like this:
/\) (?!.*\))(\S+)/
Or if you don’t want to have capture groups, but potentially slower:
/(?<=\) )(?!.*\))\S+/
(?!.*\))
is a negative lookahead. If what’s inside matches, then the whole match will fail. So, if .*\)
matches, then the match fails, in other terms, it prevents a match if there’s a )
after that position in the match.
In the second regex, (?<=\) )
is a positive lookbehind, where it ensures that there’s a )
before the match starts.
2
solved Write regular expressions [closed]