I want a regular expression to allow first character be an alphabet and then numbers only with following constraints :
-no space
-no special characters
like AS2, Nf2, nf_2, nf 08 should not be allowed.
'N00044,n0,n09,n099,123456,123' allowed
I want a regular expression to allow first character be an alphabet and then numbers only with following constraints :
-no space
-no special characters
like AS2, Nf2, nf_2, nf 08 should not be allowed.
'N00044,n0,n09,n099,123456,123' allowed
You can try this regex :
^[A-z]\d+$
if you want a minimum of 1 digit necessary, or
^[A-z]\d*$
if having a digit is not mandatory.
Jarvis's does meet the requirement but you can also use numeric range for the same since \d is specifically used for ASCII numbers. Refer when to use \d and [0-9].
Since numbers are required to be matched in your regex I would prefer as follows:
^([A-z][0-9]+)$
As per your requirement in comments, following regex should do the work for you:
^(([A-z][0-9]+)|([0-9]+))$
It will match an input with alphabet followed by numbers or an input with only numbers.