关于preg_match()函数的一点小说明
2024-08-25 19:55:23
int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] )
例子:preg_match("/php/i", "PHP is the web scripting language of choice.")
关于$pattern,定界符不一定要是 /,如 /string/。当要匹配的字符串里含有 / 时,就不能用 /作为定界符了,可以用@ #等等。如"@php@i"
例子:preg_match('@^(?:http://)?([^/]+)@i',"http://www.php.net/index.html", $matches);
另外i表示不区分大小写,但是不支持g(其他语言里表示匹配全部),匹配全部用preg_match_all()。
最新文章
- 在PowerShell中使用curl(Invoke-WebRequest)
- js加密解密
- jquery选择器(原创)<;四>;
- Python报错UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte 0xe0 in position 0: ordinal not in range(128)
- HDU Destroy Transportation system(有上下界的可行流)
- 使用Ant命令压缩JavaScript文件
- avconv转换视频
- noip 2005 等价表达式
- NAS4Free 安装配置(四)配置硬盘
- Node中npm 安装问题
- poj 2992
- poj 1011 Sticks ,剪枝神题
- 蓝桥网试题 java 基础练习 数列排序
- 2、公司部门的组成 - CEO之公司管理经验谈
- UVA 1146 Now or later
- centos7安装配置tomcat9
- get函数
- RQNOJ 3 Jam的计数法
- spring boot(一):Hello World
- [20171106]修改show spparameter的显示宽度.txt