1

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 !

3
  • 3
    can you please provide an example? what the input output should look like? Commented Aug 10, 2017 at 19:38
  • Is that a date field? Commented Aug 10, 2017 at 19:43
  • Try ^\d{2}/\d{2}/\d{4}(?:,\d{2}/\d{2}/\d{4})*$ Commented Aug 10, 2017 at 20:04

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.