使用 htaccess 中的替代 apache 工具更改正则表达式

问题描述 投票:0回答:1
regex apache
1个回答
0
投票

我已经在 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>

如果这仍然不适合您,请告诉我并提供更多详细信息以进一步排除故障。

© www.soinside.com 2019 - 2024. All rights reserved.