I need to see if a whole word exists in a string. This is how I try to do it:
if(text.matches(".*\\" + word + "\\b.*"))
// do something
It's running for most words, but words that start with a g
cause an error:
Exception in thread "main" java.util.regex.PatternSyntaxException:
Illegal/unsupported escape sequence near index 3
.*\great life\b.*
^
How can I fix this?