Reputation: 3896
I need to use an asp:RegularExpressionValidator
control in my asp.net site and I want to restrict the characters to digits and semi-colon only.
So it needs to be able to take any amount of digits and ;
Valid values:
123
123;456
123;456;789;....
What is the regex for that?
Upvotes: 0
Views: 44
Reputation: 20014
Try this simple regex: [0-9;]+
or [\d;]+
\d
match a digit [0-9];
the literal character ;
+
means that it match between one character and unlimited times, as many times as possible,
If you want to guarantee that at least numbers are present in your expression you could do this too:
@npinti has a valid point better will be: ^[\d;]+$
where ^
indicates the begging of your expression and $
the end of it.
Upvotes: 3