PHP FILTER_VALIDATE_REGEXP Filter

Definition and Usage

The FILTER_VALIDATE_REGEXP filter validates the value based on a regular expression compatible with Perl.

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

Possible options:

  • regexp - Validate the regular expression used

Example

<?php

var_dump(filter_var($string, FILTER_VALIDATE_REGEXP, 
array("options"=>array("regexp"=>"/^M(.*)/"))))
?>

Output:

string(17) "Match this string"