Jump to content

[SOLVED] preg_match help needed


5ury4

Recommended Posts

Hello everyone!

 

I need simple help with the syntax of preg_match, what I'm trying to do is to see if the user inputs any special character that is -> "@#$%^&*()+=-[]\\\';,./{}|\"

 

How should I preg_match this with a given variable say $userinput ?

 

I tried this code, but the problem with it was though it deteced # and $ but it refused to detect ! and @.

 

<?
$userinput  = "test";
if(preg_match("/\!\@\#\$\%\[\]/",$userinput)){
echo "Special Characters Found";
}
else{
echo "No SPeical character found.";
}
?>

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/44365-solved-preg_match-help-needed/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.