Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Need to have a regex for accepting alphabets or alphanumeric with the length of 6 to 15, and should not accept numeric only.
i have this one , ^[a-zA-Z0-9]+$.... but not according to my reg
Posted

Try this
^(?=.*[a-zA-Z]+.*)[0-9a-zA-Z]{6,15}$

Which I adapted after typing "Password" into the search engine at Regxlib.com[^]
 
Share this answer
 
Comments
_Asif_ 7-May-14 4:25am    
+5 :)
public bool IsAlphaNumeric(string inputString)
{
Regex r = new Regex("^[a-zA-Z0-9]+$");
if (r.IsMatch(inputString))
return true;
else
return false;
}


Verifying that textbox text contains only alphanumeric value as well as space character through Regular Expression Validator in asp.net (validation controls).

<asp:textbox id="txtName" runat="server" xmlns:asp="#unknown">

<asp:regularexpressionvalidator id="REValphaOnly" runat="server" errormessage="Please enter only alphanumeric." controltovalidate="txtName" validationexpression="^[a-zA-Z0-9]+$" xmlns:asp="#unknown">
 
Share this answer
 
Comments
CHill60 7-May-14 5:13am    
That's code not a regular expression. OP did not ask how to use the regex
Try below one.

^[A-Za-z0-9]{6,15}$

-Asif
 
Share this answer
 
Comments
CHill60 7-May-14 4:02am    
This will allow 6 - 15 numeric. Requirement is "and should not accept numeric only."

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900