我希望在 Notepad 中使用以下示例替換多行(數千行):
<ApplicationPath>F:\Objects\Trees\Conifers\North America\West\comporgel.zip</ApplicationPath>
<CommandLine />
<ApplicationPath>F:\Objects\Trees\Conifers\North America\West\Christmas.zip</ApplicationPath>
<Photo />
<ApplicationPath>F:\Objects\Trees\Conifers\North America\West\spruce1.zip</ApplicationPath>
<CommandLine />
<ApplicationPath>F:\Objects\Trees\Conifers\North America\East\spruce1.zip</ApplicationPath>
<CommandLine />
我需要搜索包含子檔案夾的所有行\West\并僅在它與匹配時才替換緊隨其后的<CommandLine />行<CommandLine>trees -nowindow</CommandLine>
輸出應如下所示:
<ApplicationPath>F:\Objects\Trees\Conifers\North America\West\comporgel.zip</ApplicationPath>
<CommandLine>trees -nowindow</CommandLine>
<ApplicationPath>F:\Objects\Trees\Confiers\North America\West\Christmas.zip</ApplicationPath>
<Photo />
<ApplicationPath>F:\Objects\Trees\Conifers\North America\West\spruce.zip</ApplicationPath>
<CommandLine>trees -nowindow</CommandLine>
<ApplicationPath>F:\Objects\Trees\Conifers\North America\East\spruce1.zip</ApplicationPath>
<CommandLine />
uj5u.com熱心網友回復:
將搜索設定為正則運算式模式:

找什么: ^(<ApplicationPath>[^<]*?\\West\\[^<] ?</ApplicationPath>\r?\n)<CommandLine />
用。。。來代替: \1<CommandLine>trees -nowindow</CommandLine>
uj5u.com熱心網友回復:
假設您正在使用支持完整正則運算式替換的 Notepad 之類的東西,您可以嘗試以下操作:
Find: (<ApplicationPath>.*\\West\\.*<\/ApplicationPath>\n)<CommandLine \/>
Replace: $1<CommandLine>trees -nowindow</CommandLine>
這是一個演示。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/411027.html
標籤:
上一篇:正則運算式拼圖
