Matching a word with pound (#) symbol in a regex
问题 I have regexp for check if some text containing word (with ignoring boundary) String regexp = ".*\\bSOME_WORD_HERE\\b.*"; but this regexp return false when "SOME_WORD" starts with # (hashtag). Example, without # String text = "some text and test word"; String matchingWord = "test"; boolean contains = text.matches(".*\\b" + matchingWord + "\\b.*"); // now contains == true; But with hashtag `contains` was false. Example: text = "some text and #test word"; matchingWord = "#test"; contains = text