I need some help to write a regex that matches a string in parentheses with nested parentheses and starts with pattern. (NOTE: the text in the 'parent' parentheses could be without nested parentheses)
Examples:
Some text (pattern: SOME TEXT THAT (I WANT TO EXTRACT)) a bit more text (another pattern: ignore that text) and may be a little more text
Result should be: SOME TEXT THAT (I WANT TO EXTRACT)
Some text (pattern: SOME TEXT THAT (I WANT TO EXTRACT)) a bit more text (another pattern: ignore that text) and may be a little more text
Result should be SOME TEXT THAT (I WANT TO EXTRACT)
Some text (pattern: SOME TEXT THAT I WANT TO EXTRACT) a bit more text (another pattern: ignore that text) and may be a little more text
Result should be SOME TEXT THAT I WANT TO EXTRACT
The RegEx I've tried like /\((pattern:?\s?([^\)]+))\)/gi
misses a nested )