Could anyone please help me writing a regex that I will use to validate a field (representing a digicode) in javascript that has to match the following criterias?
- needs to have 4 to 6 numbers (0 to 9)
- needs to have 1 * (star) or 1 # (sharp) either at the beginning or at the end
So the following works:
- 1234*
- *12345
- 56789#
- #456789
And the following doesn’t work:
- 1234
- 1*234
- *1234*
- *1234#
- 1234*#
- abcde
Many thanks!!
See it here on Regexr
You may want to read some basics about regex: What absolutely every Programmer should know about regular expressions (my own blog post) everything I used here is covered there.