I have text, for exp: Test numbers test count gggg aaaaaa
I need replace all words with count of characters 4(or other number) to "SUPER
".
What is the easiest way to do it?
Now I tried to do something this, but it not work properly:
String pattern = "[aA-zZ]+";
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(myText);
while (m.find()) {
String word = myText.substring(m.start(), m.end());
System.out.println("one word |" + word + "|");
if (m.end() - m.start() == myWord.length) {
m.replaceAll("SUPER");
}
}