The catch is username can also have $ symbol in it for example $mahanta. My regex is
\${([^}]+)}
But this does not work.As the language is java and the regex expression is String I escaped the $ with another backslash.Even added 2 more backslashes.But gives run-time exception.