Hi!
I have been having some problems with regular expressions. I want to validate user input when a bus number is entered.
Examples: 37, 37A, 37S, 37A/L, 16A/250, 16A/250K etc
The regular expression I came up with is
(^\d{1,3}[A-Z]{0,3})|(^[\d{1,3}[A-Z]{0,3}\/\d{0,3}[A-Z]{0,3}])
It validates 37, 37A, 37S but when it comes to validating 37A/L it fails. Can someone tell me where I am going wrong with this?
P.S I am using a regular expression validator for a text box. I have placed this in the ValidationExpression.
Thanks.
Prashanti.
Loading
Prashanti RaoPosted Mar 12, 2013, 7:57 AM
Prashanti RaoPosted Mar 12, 2013, 7:54 AM
The correct answer was
(^\d{1,3}[A-Z]{0,3}$)|(^\d{1,3}[A-Z]{0,3}\/\d{0,3}[A-Z]{0,3}$)
It was having problem as end of string was not specified.
VulpesPosted Mar 1, 2013, 6:04 AM
However, the real problem is that the placement of your parentheses and square brackets isn't quite right.
The following is working OK for me:
The output is: