I need to convert the characters followed by a -
in a string to uppercase.
Using Regex101, the following works like a charm:
Regex -> (\-[a-z]|\_[a-z])
Substitution -> \U$1
But I don't know how to properly translate this to a Java RegEx. Here's what I got so far:
StringBuilder str = new StringBuilder("this-is-a_test");
Pattern p = Pattern.compile("(\\-[a-z]|\\_[a-z])");
p.matcher(str).replaceAll("\\p{Lu}$1");
System.out.println(str);
What exactly am I doing wrong?