[:alpha:] doesn't really matter what you mean; rather, it simply means "any of the characters : a , h , l , p ". So dfhidbuffon contains a match for your template (namely h plus idbuffon ), while dfdidbuffon does not. (Note that matcher.find() looks for any match in the string, if you want to match the entire string exactly, you must use matcher.matches() , or you can change your template to use anchors such as ^ and $ .)
You can think of the notation found in many regular expression implementations, where [:alpha:] means "any alphabetic character"; but, firstly, the Java Pattern class does not support this notation (hint for ajb ), and secondly, for these languages ββit will take [:alpha:] appear inside the character class, for example, like [[:alpha:]] . The Java equivalent would be \p{Alpha} or [A-Za-z] if you only want to combine the letters ASCII and \p{IsAlphabetic} if you want to match any Unicode letter.
source share