PHP FILTER_VALIDATE_REGEXP Filter
What is FILTER_VALIDATE_REGEXP in PHP?
Explanation
PHP FILTER_VALIDATE_REGEXP is used to check and validate a regular expression.
Name: "validate_regexp"
ID-number: 272
Options:
regexp - specifies the regular expression to validate against
Example :
<?php
$val="Hscripts.com is a free webmaster resource";
$opt=array("options"=>array("regexp"=>"/^Hsc(.*)/"));
if(filter_var($val, FILTER_VALIDATE_REGEXP,$opt))
{
echo "Matched String";
}
else
{
echo "Not Matched String";
}
?>
Result :
Matched String
In the above example, the regular expression "/^Hsc(.*)/" is validated.