在 Notepad++ 中刪除每行第二個文字 \N

在 Notepad++ 中刪除每行第二個文字 \N

我有一個包含數百行的文本文件,類似於以下內容:

Here are some examples lines,\Nthis text needs to strip out\Ncertain,
Here are some examples lines.
Here are some.
Here are some examples lines,\Nthis text needs to.
Here are some examples lines,\Nthis text needs to strip out\Ncertain,

我要刪除的字元是第二文字\N

我看過宏,但我認為宏只記錄在頁面中輸入的內容。

我可以在 Notepad++ 中使用任何自動搜尋替換來替換第二 \N有空白嗎? (第一個\N應該保留。)

答案1

在搜尋和取代對話方塊中選擇「正規表示式」並找到以下內容:

(\\N.*)\\N

替換為:(\1注意\1後面有一個空格)

答案2

在正規表示式模式下搜尋並取代以下內容:

^(.*?\\N.*?)\\N

用。

\1 

解釋:

^表示匹配必須從行首開始。
.*?\\N匹配行中直到並包括第一個文字的所有文字\N
.*?匹配直到下一個文字的所有內容\N
與括號內的模式相符的所有內容都會由 . 傳回\1

相關內容