记事本++中的正则表达式不匹配
Regular Expression not matching in notepad++
我试图在 notepad++ 中匹配这个正则表达式,但我收到一条错误消息说它无效。
我的正则表达式:
{{#lsth:JointEntero_May_2015\|2015_May_([0-9]+)}}
我要匹配的是:
{{#lsth:JointEntero_May_2015|2015_May_8}}
为什么会失败?
有效的正则表达式是
\{\{\#lsth\:JointEntero_May_2015\|2015_May_([0-9]+)\}\}
之所以有效,是因为 {
和 }
字符必须转义才能作为文字符号进行匹配。 {}
通常用作量词,我们可以设置匹配前面模式对应的 min and/or max 个字符。见 the documentation:
{n}
Matches n
copies of the element it applies to.
{n,}
Matches n
or more copies of the element it applies to.
{m,n}
Matches m to n copies of the element it applies to, as much it can.
{n,}?,{m,n}?
Like the above, but match as few copies as they can. Compare with *? and friends.
我试图在 notepad++ 中匹配这个正则表达式,但我收到一条错误消息说它无效。
我的正则表达式:
{{#lsth:JointEntero_May_2015\|2015_May_([0-9]+)}}
我要匹配的是:
{{#lsth:JointEntero_May_2015|2015_May_8}}
为什么会失败?
有效的正则表达式是
\{\{\#lsth\:JointEntero_May_2015\|2015_May_([0-9]+)\}\}
之所以有效,是因为 {
和 }
字符必须转义才能作为文字符号进行匹配。 {}
通常用作量词,我们可以设置匹配前面模式对应的 min and/or max 个字符。见 the documentation:
{n}
Matchesn
copies of the element it applies to.
{n,}
Matchesn
or more copies of the element it applies to.
{m,n}
Matches m to n copies of the element it applies to, as much it can.
{n,}?,{m,n}?
Like the above, but match as few copies as they can. Compare with *? and friends.