Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: Regex woes...

by adamsj (Hermit)
on Jul 09, 2001 at 03:55 UTC ( [id://94868]=note: print w/replies, xml ) Need Help??


in reply to Re: Regex woes...
in thread Regex woes...

And that raises an interesting point, which probably has a trivial answer which I don't know. Why doesn't a construct like \d{1-3} make -w scream?

Even more oddly, if it's reversed to say \d{3-1}, it neither makes -w scream nor does it DWIM and match, say, -12.3, like it would if it were \d{2}.

adamsj

They laughed at Joan of Arc, but she went right ahead and built it. --Gracie Allen

Replies are listed 'Best First'.
Re: Re: Re: Regex woes...
by wog (Curate) on Jul 09, 2001 at 04:06 UTC
    -Mre=debug reveals the answer:

    ... Compiling REx `\d{3-1}' ... 1: DIGIT(2) 2: EXACT <{3-1}>(5) 5: END(0) ...

    Apparently this means the regex got compiled to match a digit, and then the literal text {3-1}. It would be nice if perl recognized that there might have been confusion with the {M,N} syntax, and thus would throw a warning, though issues of backwards compatiblity would need to be considered in doing this.

Re: Re: Re: Regex woes...
by japhy (Canon) on Jul 09, 2001 at 07:17 UTC
    If you look at regcomp.c, you'll see that when the regx parser finds an open brace, it looks for digits, and optionally followed by a comma and another optional string of digits. Anything else falls through as plaintext. (See the S_regpiece() function.)

    japhy -- Perl and Regex Hacker

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-24 20:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found