Hi!
I want to match the following patterns:
Pattern 1: 1234567
Pattern 2: 1234567;1234567;…
The user has to enter a 7-digits string. The user can provide multiple 7-digits strings but must be delimited by semicolon (;).
What regular expression should I use in this case?
Thanks.
I tried to match string that should contains 7 digits, i.e. [0-9]{7}
But the semicolon (
is optional. If the string only has 7 digits, pattern matched success. If the pattern consists of two 7-digits strings, then they should be delimited by semi-colon.
I tried various ways, but still can’t find a working regular expression.
I am not sure if this type of pattern can be matched by regular expression, but I think since there is a pattern, there should be a regular expression that can work…
I am trying to validate each of the seven digit numbers, and each seven digit numbers must be delimited by semi-colon. If the numbers are not seven-digits (e.g. alpha-numeric), validation fails.
If the 7 digits numbers are not delimited by semi-colon (e.g. comma), validation fails.
it works! you are great
thanks for your suggestion.