Reputation: 4901
I am looking for a php regex that can contain only , and - chracters.
in short i would like a regex that can match the following:
* may contain number
* may contain space
* may contain , -
i am making a php script to check if a certain string have the above or not, like a validation check. i have tried with this
^([\[\]=,{\}\0-9_-]+)$
but not working. please someone help me.
Upvotes: 1
Views: 129
Reputation: 7370
Use this:
^([\ ,0-9-]*)$
I offer you using this site to see what your regex expose.
Upvotes: 0
Reputation: 146450
The -
literal must be the first or last character in character classes. Otherwise, it's a range indicator:
^[0-9 ,-]+$
(Not sure though why you add =
and other stuff.)
Upvotes: 3