Regex to match string containing letters and only underscore
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.
- ^ 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/string
If 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.