Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Oddness with regex quantifiers

by talexb (Canon)
on Nov 23, 2010 at 21:36 UTC ( #873294=note: print w/ replies, xml ) Need Help??


in reply to Re: Oddness with regex quantifiers
in thread Oddness with regex quantifiers

    The reason for the asymmetry between {MIN,} and {,MAX} is probably that there's a zero in perl, but Inf isn't generally supported.

Hmm .. but isn't the zero implied by the null field?

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds


Comment on Re^2: Oddness with regex quantifiers
Select or Download Code
Re^3: Oddness with regex quantifiers
by moritz (Cardinal) on Nov 23, 2010 at 21:38 UTC
    Hmm .. but isn't the zero implied by the null field?

    Not if you expect .{MIN,} to match at least MIN characters. .{MIN,0} doesn't make much sense to me.

Re^3: Oddness with regex quantifiers
by ikegami (Pope) on Nov 23, 2010 at 22:01 UTC
    $ perl -E'say "aa" =~ /a{1,}/' 1 $ perl -E'say "aa" =~ /a{1,0}/' Can't do {n,m} with n > m in regex; marked by <-- HERE in m/a{1,0} <-- + HERE / at -e line 1.
Re^3: Oddness with regex quantifiers
by elef (Friar) on Nov 23, 2010 at 22:03 UTC
    Hmm .. but isn't the zero implied by the null field?

    Not really, I don't think.
    If perl accepted {,X}, I'm pretty sure some people would assume that it stood for {1,X}, not {0,X}. After all, one to X matches makes more sense than zero to X matches in many situations.
    It's propably best to force people to make an explicit choice.

      Sorry, everyone, I guess I should have said 1, not 0.

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

        No difference.
        $ perl -E'say "aaa" =~ /a{2,}/' 1 $ perl -E'say "aaa" =~ /a{2,1}/' Can't do {n,m} with n > m in regex; marked by <-- HERE in m/a{2,1} <-- + HERE / at -e line 1.

      I'm pretty sure some people would assume that it stood for {1,X}, not {0,X}.

      That says nothing without an idea of how common such an assumption would be made and an idea of the size of the negative impact making that assumption would entail.

      one to X matches makes more sense than zero to X matches in many situations.

      It makes sense in some situations, not necessarily many.

      It's propably best to force people to make an explicit choice.

      It's even better not to break backwards compatibility.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://873294]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-09-20 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (158 votes), past polls