0

If the title is not explainatory enough I will try to explain with actual examples.

If we have the examples: _(something) then the result would be something

Next example: _(something (else)) the result would be something (else)

And the last example would be _(something) _(else) ${_(yes)} and the result would be something else yes

I have the following regex atm: /_\(([^)\\/]+)\)/g but this regex does not include the last parenthesis in the second example so currently it becomes: something (else

I would appreciate if someone have any fix for this.

Thanks in advance.

Munge
  • 474
  • 5
  • 7
  • What you're looking for is a way to match "nested" or "balanced" parentheses. Pure regular expressions aren't capable of this feat, although several implementations of them have been extended to be able to handle it; see the answers to any of the many other questions on the topic. – Mark Reed Feb 12 '20 at 20:14
  • @MarkReed thanks for you comment. You led me in the right direction and I was able to find the solution to the issue. The solution is `_\(\s?(.+?\)?)\)` – Munge Feb 12 '20 at 20:50

0 Answers0