My regex pattern looks like this:
(?<=_)(.*?)(?=_)
I want replace only the first match between the two underscores (its not allways AVVI, it can be different. Same as AVVIDI):
T_AVVI_EINZELPOSTEN_TEST -> T_AVVIDI_EINZELPOSTEN_TEST
My regex pattern matches AVVI and EINZEPLOSTEN. How can i modify my regex to find only the first match AVVI?
code:
private Identifier addPrefix(final Identifier identifier) {
if (isExcluded(identifier)) {
return identifier;
}
Pattern p = Pattern.compile("(?<=_)(.*?)(?=_)");
Matcher m = p.matcher(identifier.getText());
return Identifier.toIdentifier(m.replaceAll(prefix));
}