String haystack = "hey (( howdy";
haystack.matches(".*\\b\\Q((\\E\\b.*");
Line 2 should return true, but it returns false. Is this bug in Java, or am I doing it wrong?
Edit : What I am trying to achieve is see if an user input (complete word) is present in the haystack
To do what you want you just need to search for the user input.
The problem is that
((
is not a word, therefore it can't be matched when preceded and suffixed by\b
It prints:
Note: To fit in a program that can matches both. You will probably test first if the user input is a word if yes you use boundaries if not this above solution.