例如我有:
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