I have a string with several placeholder tokens like so:
"hello $(firstname) $(lastname), you're on StackOverflow!";
Simples 🙂 I’m trying to write a regex that will look at a string like the above, and return all of the tokens which exist. For example in this case the return value should be { "firstname", "lastname" }.
I’m a beginner with Regex, this is what I tried to write:
"\$\(.+?\)"
However the matches include the $ and brackets, eg: { "$(firstname)", "$(lastname)" }
How can I modify the regex so that it only returns the text inside the brackets? I looked at this question for guidance but I cannot see how that regex works differently than mine.
without grouping:
test with grep:
or see it live here: http://regexr.com?2vke8