Well my question is simple, I want to match a string with following attributes
- No white space
- Must start with a letter
- Must not contain any other special characters other than underscore
- May contain numbers
Please help in creating such a regex.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Dissecting it:
^start of line/string[a-zA-Z]starts with a letter[a-zA-Z0-9_]*followed by zero or more letters, underscores or digits.$end of line/stringIf you need to consider Unicode, then the following is probably more sane:
This will match not only ASCII letters and digits but across all scripts that are supported by Unicode. Digits are restricted to decimal digits, only, so you won’t get Roman numerals.