0

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;


}
user1080247
  • 1,076
  • 4
  • 21
  • 51

1 Answers1

0

The syntax of your RegEx is not right. You need to add / before and after:

preg_match("/^[0-9*#+]+$/", $input))

Your RegEx seems right:

pre

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);
?>
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252