Figuring out how to implement a design in (cencered), I found the System.Text.RegularExpressions type in the .NET library that offers "full regular expression support". Upon (eventually) finding the regex language specification (you think it would be cross-referenced from the class), I noticed that it was exactly like Perl 5 regex's. I noticed that the escape codes were familiar, even the more exotic \A, \Z, and \G; and the replacement string took $digit or ${name} for captured groups, while the pattern string took \digit. Then I came upon the lazy-match quantifiers and I knew this had to be taken as-is from Perl. It even has the (?>...) stuff and a x option.

So... does this incorporate the actual Perl 5 source code, or was it written from scratch using the Perl 5 docs as a design spec?

More importantly, has anyone made a comparison in detail on how they differ? Rather than wading though the docs for a system I already know, it would be handy to just have a short list of what's different about it. Also, that's bound to be the confusing and surprising part.

After wading through this half-thought-through language, seeing mature Perl regular expressions as-is is like a breath of fresh air.

I wonder if our regex skills will get tapped by a new user base now? Nah, the feature will be pretty much ignored in favor of more brute-force way of accomplishing a problem.

—John

  • Comment on Microsoft's .NET ate a piece of Perl 5?

Replies are listed 'Best First'.
•Re: Microsoft's .NET ate a piece of Perl 5?
by merlyn (Sage) on Mar 31, 2003 at 16:46 UTC
    It's probably merely an adaptation or wholesale integration (or a reimplementation) of PCRE, which is about as close to having Perl regular expressions as you can have without actually having Perl. PCRE shows up in many places... there's a binding for Python, Ruby, and TCL, if I recall.

    Of course, PCRE will always be lying when it says "Perl compatible", because they can't have it exactly the same until they implement (?{...}), and that would require an entire Perl language. {grin}

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

      It is a reimplementation. It actually takes the regex and translates it into IL (Intermediate Language) byte code, which is in turned jitted into native machine code. It is pretty expensive to create a regex object, but they are reasonably fast at runtime (unless you recreate them every time inside a loop).
Re: Microsoft's .NET ate a piece of Perl 5?
by Aragorn (Curate) on Mar 31, 2003 at 20:48 UTC
Re: Microsoft's .NET ate a piece of Perl 5?
by Anonymous Monk on Mar 31, 2003 at 16:49 UTC

    Check if reading a match variable crashes your system. If it does they wrote it from scratch ;)

Re: Microsoft's .NET ate a piece of Perl 5?
by djantzen (Priest) on Mar 31, 2003 at 19:57 UTC

        Remember those little "career tests" we took back in school? The ones that had a bunch of questions that were supposed to match us up with a certain career? Like this one:

        Do you enjoy writing three lines of declaring classes, five more for adding attribute data, and four lines of other supporting code, all of which could have been implemented in a one-line function call?

        The people who checked "yes" to that became Java programers.

        ----
        I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
        -- Schemer

        Note: All code is untested, unless otherwise stated