php - Regex to check for single/double quotation marks and parenthesis? -


i need have make kind of filter doesn't allow user use following characters in password:

" ' ( ) 

right code got following:

if(preg_match('/"/', $password)) {     echo "illegal character found.."; } 

i'm extremely bad regex , kind of appreciated, i've been looking around answers can't seem find both checks single , double quotation marks..

try this:

preg_match('~[\'"\(\)]~', $password); // return true when of '"() in password. 

the whole code should be:

$password = '...'; if (preg_match('~[\'"\(\)]~', $password)) {     echo 'password contains bad character'; } else {     echo 'ok'; } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -