I'm looking to capitalise each part of a string that precedes/follows a special character and found this post which does the trick nicely. Only problem is it also sees characters which are special alpha characters (eg ô, ê, ë...) as part of the check. How do I get this to ignore those, or rather see them as acceptable alpha characters?
public static String capitaliseString(String word) {
String name = '';
Matcher m = Pattern.compile('(\\w+|\\W+)').matcher(word);
while (m.find())
name += m.group().toLowerCase().capitalize();
system.debug('####util_helper capitaliseString: ' + word + ' ## ' + name);
return name;
}
For example, if I pass it a string like o'hägen-daß I need it to return O'Hägen-Daß, but instead it returns O'HÄGen-Daß as it sees the ä as a special character.