正则表达式,用于在 | 之后删除所有内容(带 | ) [英] Regex for remove everything after | (with | )
问题描述
我试图为我的问题找到解决方案.
I was trying to find a solution for my problem.
输入:
This is the sample title | mypcworld
输出:
This is the sample title
我想在记事本++上使用简单的正则表达式删除|"之后的所有内容看起来真的很简单.但是我尝试了此处列出的其他一些正则表达式|.*$",但没有运气.问题是字符|"是等价于或的变更.所以请帮我解决它.
I want to remove everything comes after " | " using simple regex on notepad++ It seems to be really simple one. But I was tried with some other regex "|.*$" listed on here, but no luck. The problem was the character "|" was alteration equivalent of or. So please help me to solve it.
推荐答案
管道 |
是正则表达式中的特殊字符(意思是或"),你必须对它进行转义带有 \
.
The pipe, |
, is a special-character in regex (meaning "or") and you'll have to escape it with a \
.
使用您当前的正则表达式:
Using your current regex:
\|.*$
我已经在 Notepad++ 中尝试过,正如您所提到的,它似乎运行良好.
I've tried this in Notepad++, as you've mentioned, and it appears to work well.
这篇关于正则表达式,用于在 | 之后删除所有内容(带 | )的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!