Reputation: 5545
In c#, i gotta verify user inputs. Can someone tell me what will be the reg ex in order to verify this expression 12345-4521.
<12345> = Any five digits only
<-> = only hyphen
<4521> = Any four digits only but last digit should either be 0 or 1.
Upvotes: 0
Views: 102
Reputation: 90201
This should do it:
\d{5}-\d{3}[01]
\d
matches any digit from 0 through 9[01]
matches a 0 or 1{5}
and {3}
tells it to match exactly that number of the previous expressionThis is pretty basic stuff. When you get a chance, you should read a good tutorial, which covers this (and much more).
Upvotes: 4