例如我有:
Apple:123456789:pear
watermelon:57952161354:kfc
如何刪除“:”之前和之後的文字以獲得以下結果:
123456789
57952161354
答案1
- Ctrl+H
- 找什麼:
^[^:]+:([^:]+):[^:]+$
- 用。
$1
- 檢查環繞
- 檢查正規表示式
- Replace all
解釋:
^ # beginning of line
[^:]+: # 1 or more any character that is not colon followed by 1 colon
([^:]+) # group 1, 1 or more any character that is not colon
:[^:]+ # 1 colon followed by 1 or more any character that is not colon
$ # end of line
替代品:
$1 # content of group 1 (i.e. the digits)
給定範例的結果:
123456789
57952161354