In this example, I am using the regex pattern Basically, this will find all strings between curly brackets.

Pattern p = Pattern.compile('\\{[^{\\}]+\\}');
string S = 'Hello {Name__c} this should {Message__c}}';
Matcher m = p.matcher(s);
Set<String> matches = new Set<String>();
while(m.find()) {
    string tm =;

This is great and simple when trying to develop merge templates such as SMS, Email…