Preg match php a-zA-Z0-9 and space

if (preg_match ('/[^a-zA-Z0-9]/i', $getname)) { 

I use this preg_match pattern to check if a string in php contains charachters other than a-zA-Z0-9 . I want to add space to the template ... I use ' /[^a-zA-Z0-9 ]/i' , but it doesn’t work ... how do I do this?

I want to resolve spaces, including a-zA-Z0-9

+4
source share
2 answers
 if (preg_match ('/[a-zA-Z0-9 ]/', $getname)) { 
+2
source
 preg_match('/^[a-zA-Z0-9 ]+$/', 'string') 
0
source

Source: https://habr.com/ru/post/1332476/


All Articles