I have a rather strange problem. I am trying to find a template similar [some string][word boundary]. Simplified, my code is:
final Pattern pattern = Pattern.compile(Pattern.quote(someString) + "\\b");
final String value = someString + " ";
System.out.println(pattern.matcher(value).find());
My logic tells me that this should always infer true, no matter what someString. However:
- If it
someStringends with a word character (for example, "abc"), it is output true; - If it
someStringends with a word boundary (for example, "abc."), Is output false.
Any ideas what is going on? My current workaround is to use \Winstead \b, but I'm not sure about the consequences.
Felix source
share