Reputation: 357
I have this regular exp \d{2}/\d{2}/\d{4}
that we use to validate a string format (weird business rule)
now that field allows a comma separated list, of those strings, so I need to change the reg exp, I know how to do a it for digits, or for strings, but I cant do it for this.
can someone help me? thanks !
Upvotes: 1
Views: 40
Reputation: 626936
You may use
^\d{2}/\d{2}/\d{4}(?:,\d{2}/\d{2}/\d{4})*$
It matches your pattern first and then zero or more sequencesof a comma and your pattern. Anchors are not necessary if you use the pattern with matches
method.
Replace the comma with \s*,\s*
if there can be whitespaces around the comma.
Upvotes: 2