Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
167
rated 0 times [  172] [ 5]  / answers: 1 / hits: 17327  / 12 Years ago, thu, august 2, 2012, 12:00:00

For instance:



'1'     => NG
'243' => NG
'1av' => OK
'pRo' => OK
'123k%' => NG


I tried with



 /^(?=^[^0-9]*$)(?=[a-zA-Z0-9]+)$/


but it is not working very well.


More From » regex

 Answers
53

Use



/^(?![0-9]*$)[a-zA-Z0-9]+$/


This expression has a negative lookahead to verify that the string is not only numbers. See it in action with RegExr.


[#83908] Tuesday, July 31, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaelyn

Total Points: 619
Total Questions: 102
Total Answers: 104

Location: Honduras
Member since Sun, Dec 26, 2021
2 Years ago
;