+ Start a Discussion

Regex need to match word

Actually I am trying to match merge field in string : I am trying below but not working...

string str = '{!a.d} and {!b.d} hello';
string regex = '/\\{\\!\\w+.\\w+\\.*\\}/g';
Pattern p = Pattern.compile(regex);
Matcher pm = p.matcher(str);
system.debug('----11111111111---'+ pm.find()); 

Any help would be appreciated
NagaNaga (Salesforce Developers) 
Hi Gaurav,

Please try the below sample code

User-added imageBest Regards
Naga Kiran
No, how will this work for '{!a.d} and {!b.d} hello' ??