PHP preg_macth for the ‘special’ characters:

You can use the POSIX character class [[:punct:]] for the ‘special’ characters:

$regex = '[[:punct:]]';

if (preg_match('/'.$regex.'/', 'somepas$', $matches)) {
    print_r($matches);
}

Related posts:

This entry was posted in knowledge, php. Bookmark the permalink.