Regex prevent matching special charakter at end. \S

no grouping + trailing in light blue + main part in dark blue:

[@#]\S+(?<!\?|\!|\.)|[^@#]+

but if you want exact matches, try this:

[@#]\S+(?<!\?|\!|\.)

and if you want the 101 either, try this:

[@#]\S+(?<!\?|\!|\.)|\d+

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top