解析 - 在 wordpress 短代码之间预匹配 php 中的文本
parsing - Preg match text in php between wordpress shortcodes
你好,我想在 PHP 中使用 preg_match 从字符串中解析出以下嵌套的 Wordpress 简码。但是我的 preg 不工作。
$str = '[according-wr]
[according]
[icon]eonrolf[/icon]
[title]Title[/title]
[src]http://dcijnionc.com/rfeojf[/src]
[text]dsionodsovndsl lkdsnikndsln slodsvndx sdvopndsponvdxs ndsxpn pd.[/text]
[/according]
[/according-wr]';
preg_match_all('/\[according-wr\](.*?)\[\/according-wr\]/', $str, $matches);
var_dump($matches);
它return一个空数组!
点.
默认不匹配换行符,你需要s
修饰符:
$preg = preg_match_all('/\[according-wr\](.*?)\[\/according-wr\]/s', $str, $matches);
^ here
有关 PCRE_DOTALL
修饰符的更多信息,另请参阅 manual。
你好,我想在 PHP 中使用 preg_match 从字符串中解析出以下嵌套的 Wordpress 简码。但是我的 preg 不工作。
$str = '[according-wr]
[according]
[icon]eonrolf[/icon]
[title]Title[/title]
[src]http://dcijnionc.com/rfeojf[/src]
[text]dsionodsovndsl lkdsnikndsln slodsvndx sdvopndsponvdxs ndsxpn pd.[/text]
[/according]
[/according-wr]';
preg_match_all('/\[according-wr\](.*?)\[\/according-wr\]/', $str, $matches);
var_dump($matches);
它return一个空数组!
点.
默认不匹配换行符,你需要s
修饰符:
$preg = preg_match_all('/\[according-wr\](.*?)\[\/according-wr\]/s', $str, $matches);
^ here
有关 PCRE_DOTALL
修饰符的更多信息,另请参阅 manual。