How to control special characters when uploading a map?

0

Can you control that when uploading a flat file, if one of the rows has characters such as: !@#$%&/(/() , the system will perform some validation?

I am trying to update a record and I need to do the aforementioned validation. I was reading and I found the function preg_match , I wanted to apply it in the following way and I did not it works:

$pattern =  '/(["!@#$%&\/()]")/';

if (preg_match($pattern,$valor)) {
    echo " se encontro caracteres especiales, validar plano ";
}

In the variable $valor the field group promotion is loaded which is the one that I want to validate at the time of loading. I'm using PHP to do the form.

Why does the above code fail? How can i fix it? Is there any other way to validate?

    
asked by Norbey Martinez 09.05.2017 в 18:55
source

1 answer

2

There is a " more at the end of your expression. It works if it is deleted:

/(["!@#$%&\/()])/

And parentheses are not necessary:

/["!@#$%&\/()]/
    
answered by 10.05.2017 / 05:14
source