search
Homephp教程PHP源码php preg_match_all 与preg_match 区别与实例

<script>ec(2);</script>

/*

 代码如下 复制代码
int preg_match_all ( string $pattern , string $subject , array &$matches [, int $flags [, int $offset ]] );

搜索所有匹配正则表达式的模式并提出给予他们在比赛中受的标志指定的顺序。第一场比赛后发现,随后的搜查是继续从最后一场比赛结束。

实例

 代码如下 复制代码
preg_match_all("|]+>(.*)[^>]+>|u",
    "example:
this is a test
",
    $out, preg_pattern_order);
echo $out[0][0] . ", " . $out[0][1] . " ";
echo $out[1][0] . ", " . $out[1][1] . " ";

出输

 代码如下 复制代码

example: ,

this is a test

example: , this is a test


preg_match_all("|]+>(.*)[^>]+>|u",
    "example:

this is a test
",
    $out, preg_set_order);
echo $out[0][0] . ", " . $out[0][1] . " ";
echo $out[1][0] . ", " . $out[1][1] . " ";

 

int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags [, int $offset ]]] )
搜索主题的经常表达的方式给予配合


$subject = "abcdefwww.111cn.net";
$pattern = '/^def/';
preg_match($pattern, substr($subject,3), $matches, preg_offset_capture);
print_r($matches);


array
(
    [0] => array
        (
            [0] => def
            [1] => 0
        )

)


*/

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

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor