如何删除本文中第6个冒号之前的所有内容,例如:
123:::12423:122343:123:1234:example
1212d3:::123:123453:12333:12345:example
12dd3:::12663:1223423:123:123456:example
123:::123:123:123:1234567:example
124tsd3:::121233:123:123:12346578:example
125sdf3:::123:1254353:123:123456789:example
那么我将留下:
1234:example
12345:example
123456:example
1234567:example
12346578:example
123456789:example
答案 0 :(得分:1)
答案 1 :(得分:1)
如果你想处理除数字和单词示例之外的其他字符串:
^.+:(?=[^:]+:[^:]+$)
EMPTY
<强>解释强>
^ : begining of line
.+ : 1 or more any character
: : literally :
(?= : start lookahead, make sure we have the following after
[^:]+ : 1 or more any character but :
: : literally :
[^:]+ : 1 or more any character but :
$ : end of line
) : end lookahead
请勿检查. matches newline
给定示例的结果:
1234:example
12345:example
123456:example
1234567:example
12346578:example
123456789:example