Reputation: 77
I have this pattern in HTML for an ID login :
[0-9]{6} (need 6 numbers)
and i just learned some users have a letter before numbers so it became :
^(a|A)([0-9]{6})$
and i want to know if it's possible to join the two pattern in one (write 6number or 1 letter + 6 numbers)?
Upvotes: 0
Views: 42
Reputation:
^(a|A)?([0-9]{6})$
By adding the ? we are saying the first capturing group must appear either zero or one time.
Upvotes: 0
Reputation: 61
Yes, you can join the two patterns with the "|" character. Please, try this: [a-z]{1}\d{6}|[A-Z]{1}\d{6}
Upvotes: 1