jetbrains ide – Regex match a string within 2 different strings containing other characters

Given bar(alvin the chipmunk dude) and chipmunk(alvin the chipmunk dude), how would you match the word “chipmunk” only on the “bar” function?

Another question I just asked, but without the needed complexity I was looking for, is answered here. I do not believe this is a duplicate given the answer to the question from @revo. That answer does answer the other question however I see no way to adapt it to ensure the match is contained within two different strings (“bar(” and “)”).

chipmunk(?=[^)(\]*(?:\.[^)(\]*)*)) (courtesy of @revo) matches “chipmunk” inside of the parentheses, but I want to constrain it to only to to being within “bar(” and “)”.

Test here.

Using JetBrains IDE which uses Java.

Read more here: Source link