I've been looking into regex lately and figured that the ?
operator makes the *
,+
, or ?
lazy. My question is how does it do that? Is it that *?
for example is a special operator, or does the ?
have an effect on the *
? In other words, does regex recognize *?
as one operator in itself, or does regex recognize *?
as the two separate operators *
and ?
? If it is the case that *?
is being recognized as two separate operators, how does the ?
affect the *
to make it lazy. If ?
means that the *
is optional, shouldn't this mean that the *
doesn't have to exists at all. If so, then in a statement .*?
wouldn't regex just match separate letters and the whole string instead of the shorter string? Please explain, I'm desperate to understand.Many thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…