in reply to Explain a regex

I don't understand why \d (or even the range 0-9) wasn't used instead of the large character class, or \. wasn't used instead of the dot character class, or why * was used in one place but {0,} was use in another.

I'd say this was the work of someone who wasn't completely clued. I'd hate to see the rest of their code.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^2: Explain a regex
by BrowserUk (Patriarch) on Jan 22, 2005 at 16:29 UTC

    !?

    use Regexp::Common qw[number];; print $RE{num}{real};; (?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[ +0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))

    Examine what is said, not who speaks.
    Silence betokens consent.
    Love the truth but pardon error.

      I think that Randal's point is that just because something is on CPAN, or even in the main perl distribution (which I don't think is the case for Regexp::Common), doesn't mean that it's the most optimal, clue-filled way to do it. ;-) For example, my modules on CPAN probably would not meet with Randal's full approval either ;-)

      The first line of your sig can be safely reversed here:

      Examine who speaks, not what is said.