更新时间:2022-11-12 08:52:58
一个可能的解决办法是使用的背后正面看:
A possible solution could be to use a positive look behind:
(?<=n)n
这会给你的终点位置:
It would give you the end position of:
作为mentionned由蒂莫西·扈利中,一个正向前查找更直观
As mentionned by Timothy Khouri, a positive lookahead is more intuitive
我想preFER他主张(= NN?)N
的简单的形式:
I would prefer to his proposition (?=nn)n
the simpler form:
(n)(?=(n))
这将引用第一弦您想要的位置并会捕捉组第二n(2)
That would reference the first position of the strings you want and would capture the second n in group(2).
这是因为:
因此,组(1),组(2)将捕捉一切'N'重新presents(即使它是一个复杂的正则表达式)。
So group(1) and group(2) will capture whatever 'n' represents (even if it is a complicated regex).