[英]Notepad++ replace text between two strings spawning multiple lines and retain some part of the string in between
[英]Notepad++ Removing text between two strings if third string is present between other strings
我想刪除兩個字符串之間的文本,包括那些字符串,當且僅當這兩個字符串之間存在第三個字符串時。 如果我可以使用Notepad ++中的替換功能來執行此操作,我會更喜歡它。
這是我需要改變的模型:
asdfnjaslfjsa
asdfjaskldfsafkldj
asdfjsadfk
STRING_1
sanjvnlamf
fas g
gsegvrs
STRING_2
STRING_1
asf sf gfsjasak
qweuwiouqnv
STRING_3
awi iavbfa c
anfiab
STRING_2
STRING_1
asmorancm
anib fas
STRING_2
sdabfashbdfbc ds
改為:
asdfnjaslfjsa
asdfjaskldfsafkldj
asdfjsadfk
STRING_1
sanjvnlamf
fas g
gsegvrs
STRING_2
STRING_1
asmorancm
anib fas
STRING_2
sdabfashbdfbc ds
您正在尋找的是以下結構:
STRING_1
(?:(?!STRING_2)[\s\S])*?
STRING_3
(?:(?!STRING_2)[\s\S])*?
STRING_2
僅當STRING_3
存在於兩者之間時,這才匹配STRING_1
到STRING_2
(該技術稱為淬火貪婪令牌 )。
STRING_1(?:(?!STRING_2)[\\s\\S])*?STRING_3(?:(?!STRING_2)[\\s\\S])*?STRING_2
請參閱regex101.com上的演示 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.