I’m not that good with regular expressions…
I need a JavaScript regular expression that will do the following:
- The string can contain letters (upper and lower case), but not punctuations such as éàïç…
- The string can contain numbers (0..9) anywhere in the string, except on the first position.
- The string can contain underscores (_).
Valid strings:
- foo
- foo1
- foo_bar
- fooBar
Invalid strings:
- 1foo –> number as first character
- foo bar –> space
- föo –> punctuation ö
Many thanks!
This regex should do what you need:
Use it as follows:
Some explanation:
To learn more about regular expressions, you may find this site useful.