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

查看所有标签

Algorithms Illuminated (Part 2)

Algorithms Illuminated (Part 2)

Tim Roughgarden / Soundlikeyourself Publishing, LLC / 2018-8-5 / USD 17.99

Algorithms are the heart and soul of computer science. Their applications range from network routing and computational genomics to public-key cryptography and machine learning. Studying algorithms can......一起来看看 《Algorithms Illuminated (Part 2)》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

MD5 加密
MD5 加密

MD5 加密工具