Consider the following code snippet:
String input = \"Print this\"; System.out.println(input.matches(\"\\\\bthis\\\\b\"));
Output
System.out.println(input.matches(".*\\bthis$"));
Also works. Here the .* matches anything before the space and then this is matched to be word in the end.