Apache:mod_substitute 删除文本中所有 .html 超链接的规则

Apache: mod_substitute rule to strip out all .html hyperlinks in a text

Substitute "s|<a(.*)href=\"/(.*)\.html\"(.*)>|<ahref=\"/\">|i"

这是我正在使用的替代规则,但看起来如果在一个段落中我有多个 href,只有尾随的 href 会被删除 html 扩展名。以前的 hrefs 没有影响。

(.*)表示从这一行开始尽可能多的字符,因此匹配第一个<a后,它将搜索最远的href。如果你加一个?在 * 之后,它将寻找最小的字符串匹配 (.*?),但仍允许其余匹配。

Substitute "s|<a(.*?)href=\"/(.*?)\.html\"(.*?)>|<a href=\"/\">|i"