I have this regex: /[^a-zA-Z0-9_-]/
What I want to add to above is:
a-zA-Z
How I could make this regular expression?
The regular expression to match String which contains a digit as first character is “^[0-9]. *$”.
Using character sets For example, the regular expression "[ A-Za-z] " specifies to match any single uppercase or lowercase letter. In the character set, a hyphen indicates a range of characters, for example [A-Z] will match any one capital letter. In a character set a ^ character negates the following characters.
\Z is same as $ , it matches the end of the string, the end of the string can be followed by a line break. \z matches the end of the string, can't be followed by line break.
Match any specific character in a setUse square brackets [] to match any characters in a set. Use \w to match any single alphanumeric character: 0-9 , a-z , A-Z , and _ (underscore). Use \d to match any single digit. Use \s to match any single whitespace character.
Try something like this:
^[a-zA-Z][a-zA-Z0-9.,$;]+$
Explanation:
^ Start of line/string. [a-zA-Z] Character is in a-z or A-Z. [a-zA-Z0-9.,$;] Alphanumeric or `.` or `,` or `$` or `;`. + One or more of the previous token (change to * for zero or more). $ End of line/string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With