因为我对
re2有点新意,所以我想弄清楚如何在
Go中使用JS,C或任何PCRE风格的正向前瞻(?= regex).
以下是我正在寻找的一些例子.
JS:
'foo bar baz'.match(/^[\s\S]+?(?=baz|$)/);
蟒蛇:
re.match('^[\s\S]+?(?=baz|$)','foo bar baz')
>注意:两个例子都匹配’foo bar’
非常感谢.
根据
Syntax Documentation,不支持此功能:
(?=re)
before text matchingre
(NOT SUPPORTED)
此外,从WhyRE2开始:
As a matter of principle,RE2 does not support constructs for which only backtracking solutions are known to exist. Thus,backreferences and look-around assertions are not supported.