所以我有这样一行:
text1:text2:text3
我想使它像这样:
text1:text3
如何使用正则表达式来实现这一点?
答案1
答案2
- Ctrl+H
- 找什么:
:[^:\r\n]+(?=:)
- 用。。。来代替:
LEAVE EMPTY
- Replace all
解释:
: : a semicolon
[^:\r\n]+ : negative character class, any character that is not semicolon or linebreak
(?=:) : lookahead, make sure we have a semicolon after
- 检查正则表达式