Why does the RegEx ni?
differ from n(i)?
?
为什么RegEx ni?与n(i)不同? ?
The question mark makes the preceding token optional.
But the preceding token is essentially the same: i
and (i)
Therefore I don't understand, why I get different results.
问号使前面的标记可选。但前面的标记本质上是相同的:我和(i)因此我不明白,为什么我会得到不同的结果。
匹配n(i)?
.
Matches for ni?
(I highlighted the additional matches in green)
。匹配ni? (我突出了绿色的其他比赛)
I expected both regular expressions to match all occurrences of n
and ni
.
But in the first image, some are missing. Why ?
我希望两个正则表达式匹配所有出现的n和ni。但在第一张图片中,有些图片丢失了。为什么?
The screenshots are from Notepad++
but I encountered the same behaviour in Javascript's RegEx engine.
屏幕截图来自Notepad ++,但我在Javascript的RegEx引擎中遇到了相同的行为。
PS: Here is the sample text for you to copy/paste in case you try to reproduce my results:
PS:以下是您复制/粘贴的示例文本,以防您尝试重现我的结果:
and in this way, it has significance. Jeremy Diamond
possible with the United States. So, I think there
potentially infrastructure development. Japan, for now
who on any given morning can see something in a paper这样,它具有重要意义。 Jeremy Diamond可能与美国有关。所以,我认为有潜在的基础设施发展。日本,现在谁在任何一个早晨都可以看到纸上的东西
1 个解决方案
#1
0
Based on the discussion above, I conclude that this has to be a bug in Notepad++, because it occurs in Notepad++ 7.2.2 and also after updating to Notepad++ 7.3.3
根据上面的讨论,我得出结论,这必须是Notepad ++中的一个错误,因为它发生在Notepad ++ 7.2.2中,也发生在更新到Notepad ++ 7.3.3之后。
In case someone can alert the Notepad coders, you are very welcome.
如果有人可以提醒记事本编码员,非常欢迎您。
I don't know what went wrong in my initial javascript test case, which I simplified to this * question, but despite my initial impression the bug doesn't seem to appear in Javascript regex (as demonstrated above by @slebetman , whose results I could reproduce).
我不知道我最初的javascript测试案例出了什么问题,我将其简化为这个*问题,但是尽管我最初的印象是这个bug似乎没有出现在Javascript正则表达式中(如上所述@slebetman,其结果我可以重现)。
However, the bug in Notepad++ persists.
但是,Notepad ++中的错误仍然存在。
#1
0
Based on the discussion above, I conclude that this has to be a bug in Notepad++, because it occurs in Notepad++ 7.2.2 and also after updating to Notepad++ 7.3.3
根据上面的讨论,我得出结论,这必须是Notepad ++中的一个错误,因为它发生在Notepad ++ 7.2.2中,也发生在更新到Notepad ++ 7.3.3之后。
In case someone can alert the Notepad coders, you are very welcome.
如果有人可以提醒记事本编码员,非常欢迎您。
I don't know what went wrong in my initial javascript test case, which I simplified to this * question, but despite my initial impression the bug doesn't seem to appear in Javascript regex (as demonstrated above by @slebetman , whose results I could reproduce).
我不知道我最初的javascript测试案例出了什么问题,我将其简化为这个*问题,但是尽管我最初的印象是这个bug似乎没有出现在Javascript正则表达式中(如上所述@slebetman,其结果我可以重现)。
However, the bug in Notepad++ persists.
但是,Notepad ++中的错误仍然存在。