I need to validate VARCHAR field.
conditions are: field must contain atleast 2 AlphaNumeric characters
so please any one give the Regular Expression for the above conditions
i wrote below Expression but it will check atleast 2 letters are alphanumeric. and if my input will have other than alphanumeric it is nt validating.
‘^[a-zA-Z0-9]{2,}$’
please help………
The easy way: At least two alnum’s anywhere in the string.
Answer to comments
I never did (nor intended to do) any benchmarking. Therefore – and given that we know nothing of OP’s environment – I am not one to judge whether a non-greedy version (
[a-zA-Z0-9].*?[a-zA-Z0-9]) will be more efficient. I do believe, however, that the performance impact is totally negligible 🙂