My pattern is [a-z][\\*\\+\\-_\\.\\,\\|\\s]?\\b
My Result:
a__
not matched
a_.
pattern matched = a_
a._
pattern matched = a.
a..
pattern matched = a
why my first input is alone not matched??? Thanks in advance.
[ PS: got the same result with [a-z][\\*\\+\\-\\_\\.\\,\\|\\s]?\\b ]
Because unlike the period
., the underscore_is considered to be a word character; soa_is one word, buta.is a word with interpunction.So,
a__matchesa, then matches_, then fails to match a word boundary (since the next_is a part of the same word).a..matchesa, skips the character range, then matches the word boundary between the wordaand the interpunction..