The FILTER_VALIDATE_REGEXP constant validates a value against a Perl-compatible regular expression.
Options
regexp − The regular expression to validate against.
Return
The FILTER_VALIDATE_REGEXP constant does not return anything.
Example
<?php $val="example.com"; $res = array("options"=>array("regexp"=>"/^ex(.*)/")); if(filter_var($val, FILTER_VALIDATE_REGEXP,$res)) { echo "Matched String!"; } else { echo "Not a Matched String!"; } ?>
The following is the output.
Matched String!