regex expression which contains 9 atleast alphabets and 1 digits and the position of alphabets and digit can be anywhere.
eg-
rahulkumar1
rahul9kumar
1RahulKumar
/[A-Za-z]{9,}[0-9]{0,1}/
I have tried using this but it does not worked out.enter image description here
3
Answers
If you only want to allow chars a-z A-Z or digits:
Explanation
^
Start of string(?=[a-zA-Z]*d)
Assert at least a single digit(?:d*[a-zA-Z]){9}
Match at least 9 times a char a-zA-Z preceded by optional digits[a-zA-Zd]*
Match optional chars a-z A-Z or digit$
End of stringRegex demo
The following matched the requirements, I don’t know if it generally valid as you only gave three examples:
[a-zA-Z]*[d]{1}[a-zA-Z]*
Does this work (JS):