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