I have this JavaScript code which allows me to detect if a string contains any special characters including single and double quotations...
if (/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?`~]/.test(string) === false) {
//...
}
However when I try to do this in PHP the regex is invalid since PHP regexes have to be in quotations.
if (!preg_match('/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?`~]/', $string)) {
//...
}
How would I use this JavaScript regex in PHP? I cannot figure out a way to have a special character regex that includes quotations.
Aucun commentaire:
Enregistrer un commentaire