We got a Pattern:
Pattern TRANSLATION_RAW_PATTERN = Pattern.compile("(?<key>(\\$\\{(?<keydata>.*?)\\}))|(?<value>(.*?))")
And an Input:
${something}${something.else}
And using an online Pattern matcher this should result in the two keydata groups of:
"something" and "something.else"
But, it actually results in "something}${something.else"
String rawContents = getContents();
Matcher contentMatcher = TRANSLATION_RAW_PATTERN.matcher(rawContents);
while (contentMatcher.matches())
{
final String keyGroupMatching = contentMatcher.group("keydata");
if (keyGroupMatching == null)
{
break;
}
rawContents = rawContents.replace("${" + keyGroupMatching + "}", I18n.translateToLocal(keyGroupMatching));
contentMatcher = TRANSLATION_RAW_PATTERN.matcher(rawContents);
}
return rawContents;
This happens already on the first iteration. The first time it retrieves the group it already retrieves it wrong.
We're a bit puzzled here since all online Pattern matchers we tried return the correct groups.