function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gaurav.sfdcgaurav.sfdc 

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
gaurav.sfdcgaurav.sfdc
No, how will this work for '{!a.d} and {!b.d} hello' ??