前贪婪不起作用

时间:2016-10-19 22:32:28

标签: regex lookaround

我刚刚在正则表达式中学到了前瞻,但有一个细节让我烦恼:

% set test abcdehehfkdehemno

% regexp {([^ ])*.} $test match

1

% set match

abcdehehfkdehemno

% regexp {((?=dehe).)*.} $test match

1

% set match

a

为什么([^ ])*贪婪且((?=dehe).)*不是,我希望前瞻版本返回m而不是?

0 个答案:

没有答案