Reputation: 2185
^(((\s*[\$]?[+-]?\d*|(\d{0,3}(,?\d{3})*)(.\d+)?[\$]?)((\d+|(\d+-\d+)))?)|((\s*[\$]?[+-]?\d*|(\d{0,3}(,?\d{3})*)(.\d+)?[\$]?(\t\s*[$]?[+-]?\d*|(\d{0,3}(,?\d{3})*)(.\d+)?[\$]?)*[\n\rx]*)+))$
I have created this Regex to validate financial values: e.g. $ 22,222,222 $33,415,334 333 2d2 3d3 (this is one valid value)
Now I want to not allow just 's', 'S', 'R' and 'r' characters. But if I remove the .
(dots), it also disallows spaces and commas. I am almost done with this and don't want to break all my 2 hours effort just for not allowing these 2 characters only.
Upvotes: 0
Views: 44
Reputation: 20737
You don't show many input examples so what about using something like:
^(?: *\$ *\d+(?:,\d{3})*)*(?: \d[a-qt-z\d]\d)*$
https://regex101.com/r/nHPgnF/1
Upvotes: 1