Reputation: 3324
if (preg_match ('/[^a-zA-Z0-9]/i', $getname)) {
i use this preg_match pattern to check if a string in php contains other charachters than a-zA-Z0-9
. i want to add to the pattern the space...i use '/[^a-zA-Z0-9 ]/i'
but is not working ... how should i do it?
i want to allow spaces including a-zA-Z0-9
Upvotes: 6
Views: 36496
Reputation: 11
preg_match("/[^A-Za-z'-'_' ']/", 'string')
if you want to use space in your input field then you have to use this ' ' not this ''.
mention space between ' '
Upvotes: 1