In this example, I am using the regex pattern https://regex101.com/r/mQIU0S/1. 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 = m.group(0);
matches.add(tm.substring(1,tm.length()-1));
}
system.debug(matches);

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