java - word boundary and pattern quote not working -


string haystack = "hey (( howdy"; haystack.matches(".*\\b\\q((\\e\\b.*"); 

line 2 should return true, returns false. bug in java, or doing wrong?

edit : trying achieve see if user input (complete word) present in haystack

to want need search user input.

public static void main(string[] args) {     string test = "some text (( other text inside stack";     string userinput = "((";      pattern p = pattern.compile(".*" + pattern.quote(userinput) + ".*");     matcher m = p.matcher(test);     system.out.println(m.find()); } 

the problem (( not word, therefore can't matched when preceded , suffixed \b

it prints:

true 

note: fit in program can matches both. test first if user input word if yes use boundaries if not above solution.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -