正则表达式-匹配模式
2016-03-25 10:27
267 查看
i忽略大小写
x去除规则中的空白
U非贪婪
<?php
$str = "wo di jia zai shandong!";
preg_match('/Shandong/i', $str, $matches); //i模式表示大小写不敏感
var_dump($matches);
//忽略空白的x模式
$str = 'I love U';
preg_match('/i love u/ix', $str, $matches); //找不到了,因为x会自动将正则规则中的空白字符去除。
var_dump($matches);
//非贪婪模式U
$reg = '/<.*>/U';
$str = '<span>1111</span><span>222</span>';
preg_match_all($reg, $str, $rst);
var_dump($rst);
x去除规则中的空白
U非贪婪
<?php
$str = "wo di jia zai shandong!";
preg_match('/Shandong/i', $str, $matches); //i模式表示大小写不敏感
var_dump($matches);
//忽略空白的x模式
$str = 'I love U';
preg_match('/i love u/ix', $str, $matches); //找不到了,因为x会自动将正则规则中的空白字符去除。
var_dump($matches);
//非贪婪模式U
$reg = '/<.*>/U';
$str = '<span>1111</span><span>222</span>';
preg_match_all($reg, $str, $rst);
var_dump($rst);
相关文章推荐
- Linux下XWindow图形界面的基本概念
- 什么是Mac OS X?跟Linux有什么区别
- 匹配模式 - XSL教程 - 4
- clientX,pageX,offsetX,x,layerX,screenX,offsetLeft区别分析
- AJAX 请求区分 $_SERVER['HTTP_X_REQUESTED_WITH'] 小解
- FreeBSD5.4Release X Windows 安装笔记 (Freebsd5.4R+Gnome2.10.0)
- iOS、Mac OS X系统中编程实现汉字转拼音的方法(超级简单)
- OS X Mavericks 10.9.2 Retail VMware Image
- Mac OS X 背后的故事(二)——Linus Torvalds的短视
- Mac OS X 背后的故事(四)—— 政客的跨界
- PHP date()函数警告: It is not safe to rely on the system解决方法
- How to automatically enroll user and computer certificate in AD
- 从进程PID查找X Window ID
- CMD命令更改IP地址三招:
- MIME (Multipurpose Internet Mail Extensions)多目Internet邮件扩展
- struts-default.xml解读
- xz
- ifcfg-p1p1
- Mac os 10.9开发环境搭建
- IBM全内置服务器的发展历程