Java Regex Help on \p{Punct} -
i have next regexes, 1 \p{punct}
, other 1 without
snippet (1):
add(\s[\w\p{punct}]+)+(\s#\w+)*
snippet (2):
add(\s[\w]+)+(\s#\w+)*
if input "add purchase egg #grocery testing", result matching in (1) not matching in (2). thought happening?
your sec regex allows #
@ start of lastly matched word in string stating "add" while in sentence #
exists in word wasn't last. \p{punct}
character class includes #
character class [\w\p{punct}]
lets match
\w
alphabetic characters, digits , _
and \p{punct}
punctuation: 1 of !"#$%&'()*+,-./:;<=>?@[]^_`{|}~
which lets #grocery
matched if not lastly word.
java regex
No comments:
Post a Comment