To do what you want you just need to search for the user input.
public static void main(String[] args) {
String test = "some text (( other text inside a stack";
String userInput = "((";
Pattern p = Pattern.compile(".*" + Pattern.quote(userInput) + ".*");
Matcher m = p.matcher(test);
System.out.println(m.find());
}
The problem is that ((
is not a word, therefore it can't be matched when preceded and suffixed by \b
It prints:
true
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.