Reputation: 31
I have a text/code like this:
fsa sda ${kpp dsa } } sadf ${44} sda } fd sda sd fdas ${ads}
I would like to build a regular expression that would find all occurrences of ${soemthing}. From the code above, the matches would be:
${kpp dsa } }, ${44} sda }, ${ads}
What I have managed to come up with is this regex "\$\s*{.*?}+", but that one unfortunately doesn't do do trick and I can't think of anything that would. Could you please help me?
Upvotes: 1
Views: 152
Reputation: 8306
You are describing a non-regular language, yet you are attempting to use regular expressions. It is best to create a parser for this!
Also, to answer you main problem: the {
and }
characters have a different meaning in regular expression, you should escape them with a backslash
Upvotes: 2