简体   繁体   English

正则表达式匹配以%%开头和结尾的字符串

[英]Regex to match strings starting and ending with %%

I have a text that has multiple occurrences of variables in this format: 我有一个以这种格式出现多次变量的文本:

Example text will %%include%% these %%parameters%%

I'm trying to use this: 我想用这个:

preg_match('/%%[\\s\\S]*?%%/i',$output, $matches);

But for some reason I'm getting only the first match, any ideas? 但出于某种原因,我只得到第一场比赛,任何想法?

使用preg_match_all因为您需要多个匹配项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM