gpt4 book ai didi

regex - 正则表达式的两个部分中的字符数相同

转载 作者:行者123 更新时间:2023-12-04 21:51:27 24 4
gpt4 key购买 nike

我先说我正在使用 PHP 和 preg_replace

我创建了一些正则表达式 /(={2,6})\W+(={2,6})/ 来尝试匹配

Lorem Lorem Lorem Lorem Lorem 
==Etymology==

==Links==

Lorem Lorem Lorem Lorem Lorem

( http://pastebin.com/5kAKQM1x )

这样我就可以把它变成

Lorem Lorem Lorem Lorem Lorem 
==Etymology==
<<My Insert Here>>
==Links==

Lorem Lorem Lorem Lorem Lorem

( http://pastebin.com/aamRSXU4 )

问题是我的正则表达式也匹配

Ussher believed the whole creation process occurred on that day.

==Religious views==

===Jewish traditions===
In rabbinic writings and the

( http://pastebin.com/HJ2Vy7Md )

如何确保两边的=符号数量相同?如何以不同方式使用 {2,6}

最佳答案

使用反向引用/(={2,6})\W+\1/

关于regex - 正则表达式的两个部分中的字符数相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14706481/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com