
基本上我有一個格式的項目列表
item1:item2:item3
我需要刪除所有 item1 才能使其看起來像這樣。
item2:item3
我有大多數文字編輯器,所以哪一個最適合讓我知道,謝謝。
(ps所有的物品都是不同的,沒有一個是相同的,包括同一物品類別中的物品)
答案1
- Ctrl+H
- 找什麼:
^.+?:(.*\R)
- 用。
$1
- 檢查環繞
- 檢查正規表示式
- 取消選取
. matches newline
- Replace all
解釋:
^ # beginning of line
.+? # 1 or more any character but newline, not greedy
: # a colon
(.*\R) # 0 or more any character but newline, followed by any kind of linebreak
替代品:
$1 # content of group 1 (i.e. everything that is after the first colon)
鑑於:
item1:item2:item3
item2:item1:item3
item3:item2:item1
給定範例的結果:
item2:item3
item1:item3
item2:item1