search
Homephp教程PHP源码PHP的preg_match_all正则字符多次出现第一次出代码

PHP的preg_match_all正则字符多次出现第一次出代码
$str[1]="i我是一只小小qq:42343243      444234324";
$str[2]="我是一只小小qq联系人42343244234    fasdfdsfas";
$str[3]="我是一只小小qq42343244234    fasdfdsfas";
$preg="#(d*)(d{5,14})#";
for($i=1;$i<4;$i++){
preg_match($preg,$str[$i],$arr);
echo "<pre class="brush:php;toolbar:false">";
print_r($arr);
echo "<pre class="brush:php;toolbar:false">";
}

最简单的方法如下

preg_match_all(&#39;/(qq)+.*?(d{4,16})/i&#39;, $c, $strresult);
int preg_match_all ( string pattern, string subject, array matches [, int flags])

在 subject 中搜索所有与 pattern 给出的正则表达式匹配的内容并将结果以 flags 指定的顺序放到 matches 中。

搜索到第一个匹配项之后,接下来的搜索从上一个匹配项末尾开始。

flags 可以是下列标记的组合(注意把 preg_pattern_order 和 preg_set_order 合起来用没有意义):

 

以上就是PHP的preg_match_all正则字符多次出现第一次出代码的内容,更多相关内容请关注PHP中文网(www.php.cn)!


Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use