我需要从 wordpress 帖子中提取一些文本。这是一个不起作用的代码,我猜可能是因为正则表达式在 Expresso 上运行良好,但它在 PHP 上不起作用。
$content = get_the_content();
preg_match('\<form id="form1.*?(?=<zmfj>)\', $content, $matches);
$setupform = $matches[0];
echo $setupform;
在这种情况下,变量内容可能是:
<form id="form1" method="post" action="http://google.com"><zmfj>
所以提取结果应该是
<form id="form1" method="post" action="http://google.com">