Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
给定一个管道分隔的行:
ABC|123|pqr|cde|abc.txt|
我必须找到第三个管道分隔符并删除该行的其余部分。
下面是结果的样子。
ABC|123|pqr|
我怎样才能做到这一点?
使用下面的正则表达式搜索,它会将前三个管道捕获到组(1)中:
^(.+?\|.+?\|.+?\|).*
然后将其替换为捕获的组。
\1