I need to create RegEx for two different states and I am having some trouble. Here are the requirements; one is for Washington DC and and the other for Delaware:
1) DISTRICT OF COLUMBIA (DC)
- 开发者_StackOverflow社区Format: 9 Numeric (SSN) or 7 Numeric2) DELAWARE (DE)
- Format: 1-7 Numeric
The RegEx I have for DC is ^(\d{7}|(\d{9})$
which doesnt seem to work.
I think I have the one for Delaware ^(\d{1,7})$
If you're still having problems try this. I moved the parenthesis around to enclose both conditions at once.
^(\d{7}|\d{9})$
Another posiibility which should work aswell is:
^\d{7}(\d{2})?$
In your DC regex, you've got a parenthesis after the 7, where there should be a closing curly bracket.
For the DC expression, you have some syntax errors. Try:
^(\d{7})|(\d{9})
精彩评论