develooper Front page | perl.beginners | Postings from March 2023

Re: A Regular Expression Problem in Perl 5.28

Thread Previous | Thread Next
From:
Sam
Date:
March 28, 2023 21:34
Subject:
Re: A Regular Expression Problem in Perl 5.28
Message ID:
5e43ba7c-a45d-278b-6e27-3b91243b940a@net153.net
On 3/28/23 16:07, Uri Guttman wrote:
> On 3/28/23 17:01, Martin McCormick wrote:
>> Uri Guttman <uri@perlhunter.com> writes:
>>> why are you escaping the {}?? those are meta chars that are needed to 
>>> make
>>> that a 5+ range. just delete the backslashes on them and it will work.
>>     First, thank you but read on, please.
>>     I couldn't agree more.  That should do it but when I
>> don't escape them, I get:
>>
>> Nested quantifiers in regex; marked by <-- HERE in m//^\d+{ <-- HERE 
>> 3,}// at ./regex line 10.
>>
> you also quoted the whole regex in '' but included the // which are the 
> normal regex delimiters. remove the outer quotes.
> 
> and use the qr// form for regexes.
> 
> and you don't want the + after the \d as the {5,} is the count. you 
> can't have both types of repeat counts.
> 
> my $re = qr/^\d{5,}/ ;
> 
> that should be all you need.
> 
> read perlretut to learn more regex basics. you have escaping and quoting 
> mistakes in the original.
> 
> uri
> 

I would think /^\d{5,6}/ would be what is needed? He wanted 5 or 6 digits.

--Sam

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About