regex - Regular expression with a set with a character followed by a character -
I am writing a regular expression in Java to capture some words without spaces. Words can contain only letters, numbers, hyphens, and dots. Character set [\ w + \ - \\.] The job is okay now I want to edit the set to allow a single space after the dot. How do I edit my regular expression?
You can add matching to this additional requirement
( [\ W \ -.] | (? & Lt; = \.)) + See this
(? & Lt; = \. ) is one that ensures that the location is only matched, if it occurs before a dot.
Other signals:
-
\ wUnderscore and default only to matches ASCII characters / points if you focus on Unicode , Then useUNICODE_CHARACTER_CLASSmodifier or\ p {L}andto enable Unicode forto match the Unicode characters and digits.\ w. \ P {Nd} -
You do not need to avoid the dot in any square class.
-
In your character group you have
\ w +, do you know that you can add "+" characters for acceptable characters?
Comments
Post a Comment