August 12, 2012

Regular Expression, match ${ANY_TEXT}

Question by CappY

Can you please help me with reg ex. I cant make it 🙁 I hate regex.
I need to match this string ${ANY_TEXT} .Exactly one “${” and exactly one closing tag “}”.

Thanks a lot. 🙂

Answer by Shi

${[^}]+} will match it. It will match ${ABC} from ${ABC}}} as well. If you want to match complete lines, simply anchor the regular expression using ^${[^}]+}$.

A good site to learn regular expressions is

Answer by Starx

I suppose this covers all the texts.


Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+


Please fill the form - I will response as fast as I can!