I have used php preg_replace
function to allow only alphanumeric character from a variable string. The code is given below. This code works fine.
But now I want to allow some special characters like ~!@#$%^&*()_+/
etc along with alphanumeric characters. How to do this?
$hashh=$_GET['hash'];
$hash = preg_replace("/[^a-zA-Z0-9]+/", "", $hashh);
Try this
$regex = "/[^a-zA-Z0-9~!@#$%^&*()_+\/]+/";
$string = "Th3 4ll0w3d P4rt5 4r3 ~!@#$%^&*()_+/";
$preg = preg_replace($regex, '', $string);
echo $preg;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.