3
Answers

Regular Expression Forward Slash

Prashanti Rao

Prashanti Rao

11y
5.8k
1
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.
Answers (3)