简体   繁体   English

记事本中的正则表达式不匹配

[英]Regular Expression not matching in notepad++

I am trying to match this regular expression in notepad++, but I am getting an error saying that it is invalid. 我正在尝试在notepad ++中匹配此正则表达式,但是却收到一条错误消息,说它无效。

My Regex: 我的正则表达式:

{{#lsth:JointEntero_May_2015\|2015_May_([0-9]+)}}

What I am trying to match: 我要匹配的是:

{{#lsth:JointEntero_May_2015|2015_May_8}}

Why is it failing? 为什么会失败?

The regex that works is 有效的正则表达式是

\{\{\#lsth\:JointEntero_May_2015\|2015_May_([0-9]+)\}\}

It is working because the { and } characters must be escaped in order to get matched as literal symbols. 之所以起作用,是因为必须转义{}字符才能将它们作为文字符号进行匹配。 {} are usually used as quantifiers where we can set min and/or max characters corresponding to the preceding pattern to match. {}通常用作量词,在这里我们可以设置与前面的模式相对应的最小和/或最大字符来进行匹配。 See the documentation : 请参阅文档

{n} {N}
Matches n copies of the element it applies to. 匹配n个适用于该元素的副本。
{n,} {N,}
Matches n or more copies of the element it applies to. 匹配它所适用元素的n或多个副本。
{m,n} {M,N}
Matches m to n copies of the element it applies to, as much it can. 尽可能匹配m到n个它应用于的元素的副本。
{n,}?,{m,n}? {N,}?,{M,N}?
Like the above, but match as few copies as they can. 像上面一样,但是要尽可能少地匹配副本。 Compare with *? 与之比较 *? and friends. 和朋友。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM