regex - Regular Expression to validate the field: field must contain atleast 2 AlphaNumeric characters -


i need validate varchar field. conditions are: field must contain atleast 2 alphanumeric characters

so please 1 give regular expression above conditions

i wrote below expression check atleast 2 letters alphanumeric. , if input have other alphanumeric nt validating.

'^[a-za-z0-9]{2,}$'

please help.........

[a-za-z0-9].*[a-za-z0-9] 

the easy way: @ least 2 alnum's anywhere in string.


answer comments
never did (nor intended do) benchmarking. therefore - , given know nothing of op's environment - not 1 judge whether non-greedy version ([a-za-z0-9].*?[a-za-z0-9]) more efficient. do believe, however, performance impact totally negligible :)


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -