php 正则表达式中的#号

WBOY
Release: 2016-06-23 13:49:06
Original
1498 people have browsed it

最近在研究discuz 的源码的时候发现了其中的一个正则表达式大致是这么写的preg_match(‘#^[a-z]#’,"");

一开始一下子懵了,这个是先匹配#吗?那么^不是表示以什么开始吗?这不矛盾了.于是去官网看了下关于preg_match的使用方法,找了几个例子大概都是:

if (preg_match("/\bweb\b/i", "PHP is the web scripting language of choice.")) {    echo "A match was found.";} else {    echo "A match was not found.";}
Copy after login

其中对pattern的定义都是以//来包起来的,后来进过测试,发现##是可以替代//的,这样一解释,就一切都明白了,学习的东西越深入,我们就会发现我们其实不知道的东西越多,知道的东西圈越大,他周围未知的边长就越长。



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template