i have function to validate user input a against numbers-special chars pattern (no alpha)but i have not do it exactly,and i searched over the internet to find such this but i not find,any help
function validate_num($input){
return ( ! preg_match("^[0-9*#+]+$", $input)) ? FALSE : TRUE;
}
The syntax of your RegEx is not right. You need to add /
before and after:
preg_match("/^[0-9*#+]+$/", $input))
Your RegEx seems right:
The example from the manual looks like this:
<?php
$subject = "abcdef";
$pattern = '/^def/';
preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 3);
print_r($matches);
?>
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.