小编fis*_*her的帖子

正则表达式模式 - 引用函数

我在一个论坛上发现了这个正则表达式:

"/\+?\)\)(=.+?,.+?)?\](.+?)\[\/quote\](?!((.*?)\[\/quote\]))/s"
Run Code Online (Sandbox Code Playgroud)

正则表达式应该能够从字符串中提取数据.我会举个例子:

<?php
$string = ‘[quote=username]bla bla bla bla[/quote]’;

preg_match("/\+?\)\)(=.+?,.+?)?\](.+?)\[\/quote\](?!((.*?)\[\/quote\]))/s", $string, $match, null, 0);

print_r($match);
Run Code Online (Sandbox Code Playgroud)

...但是,没有任何内容返回$ match.我猜这个正则表达式有问题,因为它应该返回'username'和'bla bla bla bla'.我将在论坛中使用该函数作为引用函数.

在此先感谢,fischer

php regex

1
推荐指数
1
解决办法
524
查看次数

标签 统计

php ×1

regex ×1