Fix upperInitial/lowerTrail behavior when there are apostrophes (e.g. He'll)

@see https://www.filebot.net/forums/viewtopic.php?f=5&t=4500
This commit is contained in:
Reinhard Pointner 2016-12-14 23:58:54 +08:00
parent 6342efc743
commit e7a4140426
1 changed files with 2 additions and 1 deletions

View File

@ -192,12 +192,13 @@ public class ExpressionFormatMethods {
}
public static String replaceHeadTail(String self, Function<String, String> head, Function<String, String> tail) {
Matcher matcher = compile("\\b(\\p{Alnum})(\\p{Alnum}*)\\b", UNICODE_CHARACTER_CLASS).matcher(self);
Matcher matcher = compile("\\b(['`´]|\\p{Alnum})(\\p{Alnum}*)\\b", UNICODE_CHARACTER_CLASS).matcher(self);
StringBuffer buffer = new StringBuffer();
while (matcher.find()) {
matcher.appendReplacement(buffer, head.apply(matcher.group(1)) + tail.apply(matcher.group(2)));
}
return matcher.appendTail(buffer).toString();
}