Python Forum
RE-greedy or non greedy about '?'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RE-greedy or non greedy about '?'
#5
@buran,Thanks! understood totally.
if anyone also have the same question, I hope this post will help to understand what's the real meaning of '?'
summary:
'?' quantifier matches between zero and one times, as many times as possible. In other words, there are two options, 0 times or 1 times; '?' quantifier selects '1 times', not '0 times', it means '?' is greedy, it wants more. I think that's the reason it's called greedy.
'??' quantifier matches between zero and one times, as few times as possible. In other words, '??' quantifier selects '0 times'.I think that's the reason it's called lazy or non-greedy.
Reply


Messages In This Thread
RE-greedy or non greedy about '?' - by frank0903 - Jun-01-2020, 04:17 AM
RE: RE-greedy or non greedy about '?' - by buran - Jun-01-2020, 04:38 AM
RE: RE-greedy or non greedy about '?' - by buran - Jun-01-2020, 08:17 AM
RE: RE-greedy or non greedy about '?' - by frank0903 - Jun-01-2020, 10:00 AM
RE: RE-greedy or non greedy about '?' - by buran - Jun-01-2020, 10:03 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020