This question already has an answer here:
- How do I allow spaces in this regex? 6 answers
I am trying to match a regular expression in PHP, using the following code.
if (!preg_match("/^[a-zA-Z0-9-_.]*$/",$string)) {
// Show error
}
I want to allow
- Integers (0-9)
- Characters (small letters and capital letters) (a to z and A to Z)
- Dots ( . )
- Underscore ( _ )
- Dash ( - )
- Space ( )
It does not work. Does anyone have any suggestions for what I am doing wrong?
</div>