Hi, is there any preg_match only allow a-zA-Z0-9():[space] ? Please help me =(

Member Avatar for diafol

I'm no brain on regex, but I think this works, with limited testing...

$pattern = "/[A-Za-z0-9:() ]/";
$subject = "#How# #912# #:m:# #(@)# #-_-#";
$replace = "?";
$m = preg_replace($pattern,$replace,$subject);

echo $m;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.