I have a lot of confusion in regex and am trying to solve them. Here I have the following line:
{start}do or die{end}extended string
My two different regular expressions, where I just repositioned the point:
(.(?!{end}))* //returns: {start}do or di //^ See here ((?!{end}).)* //returns: {start}do or die //^ See here
Why does the first regular expression eat the last "e"?
And also how does this negative look make this quantifier not greedy? I mean, why can't it consume characters outside of {end}?
javascript string php regex lookahead
Al-zami
source share