I tried \b (This means the last character of a word) in the Java Regexp, but this doesn’t work.
String input = "aaa aaa";
Pattern pattern = Pattern.compile("(a\b)");
Matcher matcher = pattern.matcher(input);
while (matcher.find()) {
System.out.println("Found this wiki word: " + matcher.group());
}
What in the problem?
In Java,
"\b"is a back-space character (char0x08), which when used in a regex will match a back-space literal.You want the regex
a\b, which in java is coded by escaping the back-slash, like this:btw, you are only partially correct about the meaning of regex
\b– it actually means “word boundary” (either the start or end of a word).