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.
Considering you want to check for ASCII Alphanumeric characters, Try this: "^[a-zA-Z0-9]*$" . Use this RegEx in String. matches(Regex) , it will return true if the string is alphanumeric, else it will return false.
In computing, the standard alphanumeric codes, such as ASCII, may contain not only ordinary letters and numerals but also punctuation marks and math symbols.
You can use regular expressions to achieve this task. In order to verify that the string only contains letters, numbers, underscores and dashes, we can use the following regex: "^[A-Za-z0-9_-]*$".
So we know that there must be at least one "alphabetic" character in there somewhere:
[a-zA-Z]
And it can have any number of alphanumeric characters (including zero) either before it or after it, so we pad it with [a-zA-Z0-9]*
on both sides:
/^[a-zA-Z0-9]*[a-zA-Z][a-zA-Z0-9]*$/
That should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With