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:

  • \ w Underscore and default only to matches ASCII characters / points if you focus on Unicode , Then use UNICODE_CHARACTER_CLASS modifier or \ p {L} and to enable Unicode for \ w . \ P {Nd} to match the Unicode characters and digits.

  • 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

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -