I'm trying to make a function that allows a string only certain characters, but it's not working. Here is my code:
$passRegex = '/[^A-Za-z0-9!\";#\$%&\'\(\)\*\+,-\./\:;<=>\?@\[]^_`\{\|}]/';
if(preg_match($passRegex, $str)) // invalid
But it throws
Warning: preg_match(): Unknown modifier '\'
This is the char list I want to allow:
!\";#$%&'()*+,-./:;<=>?@[]^_`{|}~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ