[英]How do I remove everything beyond the second occurrence of a character using Regex?
I have a list that is something like:我有一个类似的列表:
xxxxx|xxxxxx|xxxxx@example.com
xxxxx|xxxxxx|xxxxx@example.com
xxxxx|xxxxxx|xxxxx@example.com
The x's can be both letters and numbers, but nothing else. x 既可以是字母也可以是数字,但不能是别的。
What I am trying to do is replace everything (including the character) to the right of the second |
我要做的是替换第二个右侧的所有内容(包括字符) |
. . The outcome should look like:结果应如下所示:
xxxxx|xxxxx
I want to do it with regex so that I can replace all the occurrences in Notepad++.我想用正则表达式来做,这样我就可以替换 Notepad++ 中的所有出现。
Find寻找
^([^|]*|[^|]*)|.*$
Replace with用。。。来代替
\1
Reference: http://www.scintilla.org/SciTERegEx.html参考: http://www.scintilla.org/SciTERegEx.html
Replace \|[^\|]+$
with nothing.将\|[^\|]+$
替换为空。
This will match |xxxxx@example.com
, so if you replace it with a blank string, that will accomplish what you want.这将匹配|xxxxx@example.com
,所以如果你用空白字符串替换它,那将完成你想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.