我已经在 regex101.com 上生成了您想要完成的示例。一般规则是:
(<hr.+?>)(?:\s+)(<center>)
替换为:
$1<p class="somenew"></p>$2
根据 mod_substitute
的
文档,这是用于实现您的目标的适当
.htaccess
语法:
<Location "/">
AddOutputFilterByType SUBSTITUTE text/html
SubstituteMaxLineLength 10m
Substitute "s|(<hr.+?>)(?:\s+)(<center>)|$1<p class=\"somenew\"></p>$2|i"
</Location>
如果这仍然不适合您,请告诉我并提供更多详细信息以进一步排除故障。