PHP FILTER_VALIDATE_REGEXP 过滤器

PHP 教程 · 2019-01-25 22:59:07

定义和用法

FILTER_VALIDATE_REGEXP 过滤器根据兼容 Perl 的正则表达式来验证值。

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

可能的选项:

  • regexp - 规定验证所依据的正则表达式

实例


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

代码的输出如下所示:


string(17) "Match this string"


点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

Elements of Programming

Elements of Programming

Alexander A. Stepanov、Paul McJones / Addison-Wesley Professional / 2009-6-19 / USD 39.99

Elements of Programming provides a different understanding of programming than is presented elsewhere. Its major premise is that practical programming, like other areas of science and engineering, mus......一起来看看 《Elements of Programming》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试