Pattern.compile() throws exception
问题 I am using a regex to find if a string is present in a book page. Below is the code for the same. String regex = ".*\\b.{0}" + searchText + ".{0}.*\\b"; Pattern pattern = Pattern.compile(regex); pattern.matcher("This is the text area where I am trying to look for the particular text, which is in the variable searchText. This text will have the string (222M) as part of this string. The find method should give me a true result even if I don't enter the closing brakect of the word. This is a