Match hastags?

How can I check if the hash tag contains special character and if so show error please help?

$message = "#test/ #test* #*test #t*test";

preg_match_all('/(#\w+)/', $message, $matches);
foreach ($matches[1] as $hashtag)

$hashtag = preg_replace('/[^A-Za-z0-9\-]/', '', $hashtag);

if ($hashtag && !preg_match("/^[0-9a-zA-Z ]+$/", $hashtag))
    $post->set_error("ERROR - Hash tag can't contain special characters!");

Looks like solved it with this regular expression:


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.