How to use FILTER VALIDATE REGEXP in PHP

This article describe about FILTER_VALIDATE_REGEXP Filter in PHP.
  • 7741

FILTER_VALIDATE_REGEXP Filter

For validates values against a Perl-compatible regular expression FILTER_VALIDATE_REGEXP Filter used.

  • Name: "validate_regexp"
  • ID-number: 272

Possible options:

regexp - define the regular expression to validate against

Example

<html>
<body>
<?php
$string = "Match string";
var_dump(filter_var($string, FILTER_VALIDATE_REGEXP,
array("options"=>array("regexp"=>"/^M(.*)/"))))
?>
</body>
</html>

Output

filtervalidateregexpphp.jpg

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.