我是正则表达式的新手,你能告诉我下面打印的字符串的preg_match解决方案吗?
{foreach $gobar}
Anything here
{/foreach}
感谢。
答案 0 :(得分:0)
/\{foreach \$gobar\}\s+(.*)\s+\{\/foreach\}/
参考:
http://www.regular-expressions.info/anchors.html
http://www1.cs.columbia.edu/~lennox/perlre.html
答案 1 :(得分:0)
if (preg_match('#\{foreach \$gobar\}\n(.*)\n\{\/foreach\}#', $yourData, $matches)) {
echo $matches[1]; // "Anything here"
}