I hope you're doing well. I'm currently working on a PHP project and I'm facing a bit of an issue with form validation. I want to create a regular expression that only allows alphanumeric characters, dashes, and underscores in a certain input field.
For example, I have a field where users can enter a username. I want to make sure that the username only contains letters (uppercase and lowercase), numbers, dashes, and underscores. Any other special characters or spaces should not be allowed.
I've been searching online for a while but haven't found a suitable solution yet. Can anyone help me out with this? It would be great if you could provide the regex pattern that I can use in my PHP code for form validation.
Thanks in advance for your assistance!