![1文字の前後のテキストを削除するにはどうすればいいですか](https://rvso.com/image/1576189/1%E6%96%87%E5%AD%97%E3%81%AE%E5%89%8D%E5%BE%8C%E3%81%AE%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%82%92%E5%89%8A%E9%99%A4%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF%E3%81%A9%E3%81%86%E3%81%99%E3%82%8C%E3%81%B0%E3%81%84%E3%81%84%E3%81%A7%E3%81%99%E3%81%8B.png)
たとえば、次のようなものがあります:
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