如何删除||在记事本++上使用正则表达式从字符串末尾开始表达式?
How to remove || expressions from end of string using regex on notepad++?
我有这样的字符串
न च <तुल्य-गुणः>K1 दूष्यः न दोषः प्रकृतिः भवेत्|| 11 ||
उक्ताः महाचतुष्पादे येषु आयत्तं <भिषक्-जितम्>T3|| 24 ||
我的目标是删除数字和 ||它们包含在字符串末尾的符号中。我尝试使用此表达式 \|\|[0-9.]+\|\|
但它仅适用于少数情况。我可以试试什么表情?请注意我是在 Notepad++ 上做的。
因为您只关心字符串的结尾,所以您需要使用 $
所以尝试:(\s*\|\| [\d]* \|\|)$
并替换为空文本框。
点击后Replace All
使用
\|\|(?:\h+\d+\h+\|\|)+$
参见proof。
解释
--------------------------------------------------------------------------------
\| '|'
--------------------------------------------------------------------------------
\| '|'
--------------------------------------------------------------------------------
(?: group, but do not capture (1 or more times
(matching the most amount possible)):
--------------------------------------------------------------------------------
\h+ horizontal whitespace (1
or more times (matching the most amount
possible))
--------------------------------------------------------------------------------
\d+ digits (0-9) (1 or more times (matching
the most amount possible))
--------------------------------------------------------------------------------
\h+ horizontal whitespace (1
or more times (matching the most amount
possible))
--------------------------------------------------------------------------------
\| '|'
--------------------------------------------------------------------------------
\| '|'
--------------------------------------------------------------------------------
)+ end of grouping
--------------------------------------------------------------------------------
$ before an optional \n, and the end of the
string
我有这样的字符串
न च <तुल्य-गुणः>K1 दूष्यः न दोषः प्रकृतिः भवेत्|| 11 ||
उक्ताः महाचतुष्पादे येषु आयत्तं <भिषक्-जितम्>T3|| 24 ||
我的目标是删除数字和 ||它们包含在字符串末尾的符号中。我尝试使用此表达式 \|\|[0-9.]+\|\|
但它仅适用于少数情况。我可以试试什么表情?请注意我是在 Notepad++ 上做的。
因为您只关心字符串的结尾,所以您需要使用 $
所以尝试:(\s*\|\| [\d]* \|\|)$
并替换为空文本框。
点击后Replace All
使用
\|\|(?:\h+\d+\h+\|\|)+$
参见proof。
解释
--------------------------------------------------------------------------------
\| '|'
--------------------------------------------------------------------------------
\| '|'
--------------------------------------------------------------------------------
(?: group, but do not capture (1 or more times
(matching the most amount possible)):
--------------------------------------------------------------------------------
\h+ horizontal whitespace (1
or more times (matching the most amount
possible))
--------------------------------------------------------------------------------
\d+ digits (0-9) (1 or more times (matching
the most amount possible))
--------------------------------------------------------------------------------
\h+ horizontal whitespace (1
or more times (matching the most amount
possible))
--------------------------------------------------------------------------------
\| '|'
--------------------------------------------------------------------------------
\| '|'
--------------------------------------------------------------------------------
)+ end of grouping
--------------------------------------------------------------------------------
$ before an optional \n, and the end of the
string