Re: Question about perlreref - are {n} and {n}? different?
- From: "Dr.Ruud" <rvtol+news@xxxxxxxxxxxx>
- Date: Wed, 26 Oct 2005 23:26:56 +0200
usenet@xxxxxxxxxxxxxxx schreef:
> perlreref::QUANTIFIERS says:
>
> Quantifiers are greedy by default -- match the longest leftmost.
> Maximal Minimal Allowed range
> ------- ------- -------------
> {n,m} {n,m}? Must occur at least n times but no more than m times
The 'Must occur ... no more than m times' is not accurate.
#!/usr/bin/perl -w
use strict;
my $s = 'a'x100; # is more than 50 times
sub run {
local ($,, $\) = (' ', "\n");
my $re; ($re, $_) = @_;
s/$re/$1/;
print length, length($1);
}
run 'a{10,50}?(.*)' , $s;
run 'a{10,50}?(.*?)a', $s;
run 'a{10,50}?(.*?)' , $s;
run 'a{10,50}(.*?)' , $s;
run 'a{10,50}(.*)' , $s;
output:
90 90
89 0
90 0
50 0
50 50
--
Affijn, Ruud
"Gewoon is een tijger."
.
- Follow-Ups:
- Re: Question about perlreref - are {n} and {n}? different?
- From: Joe Smith
- Re: Question about perlreref - are {n} and {n}? different?
- From: Juha Laiho
- Re: Question about perlreref - are {n} and {n}? different?
- From: usenet
- Re: Question about perlreref - are {n} and {n}? different?
- References:
- Prev by Date: Re: Question about perlreref - are {n} and {n}? different?
- Next by Date: Re: MLDBM tie is very slow
- Previous by thread: Re: Question about perlreref - are {n} and {n}? different?
- Next by thread: Re: Question about perlreref - are {n} and {n}? different?
- Index(es):
Relevant Pages
|