I need to write some Javascript to check an input to only allow number and letter and ‘-‘ and ‘_’ and space bar.
Here is my regular expression
var pattern = /^([a-zA-Z])([a-zA-Z0-9_-]){1,80}$/;
Above regex does not include space bar. How can I add space bar condition into my regex.
For me this:
works.
Maybe you ran into the issue with trying it like this ?
and the regex Parser thought you ment “underscore to spacebar” and not “underscore dash and spacebar ?
(Didn’t test that)
Edit
Did a little testing
Do i guess i was right with my assumption 😉
Secound Edit in Response to OPs Comment: