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 worda
and the interpunction.
.