[英]How do I delete everything after the 3rd 4rth occurrence of a character using sed/grep/regex
[英]How do I remove everything beyond the second occurrence of a character using Regex?
我有一个类似的列表:
xxxxx|xxxxxx|xxxxx@example.com
xxxxx|xxxxxx|xxxxx@example.com
xxxxx|xxxxxx|xxxxx@example.com
x 既可以是字母也可以是数字,但不能是别的。
我要做的是替换第二个右侧的所有内容(包括字符) |
. 结果应如下所示:
xxxxx|xxxxx
我想用正则表达式来做,这样我就可以替换 Notepad++ 中的所有出现。
将\|[^\|]+$
替换为空。
这将匹配|xxxxx@example.com
,所以如果你用空白字符串替换它,那将完成你想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.