Jorge Almeida:
> On Mon, 22 Jan 2024 at 13:00, <k...@aspodata.se> wrote:
> > Jorge Almeida:
> > > $ perl -e 'exit(10) if "aaa"=~/a{,2}/;'
...
> >   {,n}        Match at most n times
...
> Yes, I read it (several times). I still don't understand it (I understand
> what you're saying, and I trust you're right, I just don't understand how
> this behaviour matches the description above--- "at most", really?)

Just think it like this:
 on the table there is three diamonds,
 can you find zero, one, or preferable two diamonds there ?
...
> Now, in
> perl -e 'print $1,"\n" if "aaa"=~/(a{,2})/;'
> $ aa
> this is understandable. More or less. Maybe the semantics of /a{,2}/ should
> be described as "match any number of consecutive 'a' whatsoever and capture
> at most 2  'a' characters...

No, it just looks at the first two a's and finds a match, there is 
still one "a" left, but who cares, you have already got your match.

Regards,
/Karl Hammar



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to