I have created the following regex which matches either 9 consecutive numbers or 14 consecutive numbers.
^[0-9]{14}$|^[0-9]{9}$
How can I make this regex match 9 consecutive numbers or 14 consecutive numbers or null values?
Basically I want to modify the regex so that a user does not need to enter a value for this field. Or in other words making the validation for this field optional.
How about:
If string is empty, it will pass; if non-empty, it must match the regex.
Regex only solution: