Latest web development tutorials

PHP FILTER_VALIDATE_REGEXP filter

PHP Filter Reference Complete PHP Filter Reference

Definition and Usage

FILTER_VALIDATE_REGEXP filters to verify the value based on the Perl-compatible regular expressions.

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

Possible options:

  • regexp - verification provisions are based on regular expressions

Examples

<?php
$string = "Match this string";

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

Output code is as follows:

string(17) "Match this string"


PHP Filter Reference Complete PHP Filter Reference