我想添加一个问题的解决方案。关于解析。例如,我想将 部分en
从更改br
为https://MyWebsite.com/en/
,以表示和https://MyWebsite.com/br/
之间的所有链接。<!DOCTYPE html>
<body>
html 代码现在的样子如下:
<!DOCTYPE html>
<link rel="canonical" href="https://MyWebsite.com/en/the-edge-of-the-ice.html" />
..
"@id": "https://MyWebsite.com/en/my-name-is-prince.html"
..
<meta property="og:url" content="https://MyWebsite.com/en/other-link.html"/>
<body>
输出将是:
<!DOCTYPE html>
<link rel="canonical" href="https://MyWebsite.com/br/the-edge-of-the-ice.html" />
..
"@id": "https://MyWebsite.com/br/my-name-is-prince.html"
..
<meta property="og:url" content="https://MyWebsite.com/br/other-link.html"/>
<body>
答案1
我的解决方案
搜索:(?:.*?<!DOCTYPE html>|\G).*?MyWebsite.com/\Ken(.*?)(?=\.html.*?<body>)
替换为:br\1\3
- 查看 环绕
- 查看 正则表达式
- 查看
. matches newline
- Replace all
因此,此解决方案的模式是:
(?:.*?REGION-START|\G).*?FIND-REGEX\K(.*?)(?=END-REGEX.*?REGION-FINAL)