On Thu, Nov 13, 2003 at 04:11:25PM -0600, Michael Howell wrote: > I'm more or less a newbie to Perl, so can you explain why your form is > better? All I see is 2 distinct ways of selecting from a set.
Well, it's kind of a long discussion about backtracking and state machines ... ;) I'd recommend "Mastering Regular Expressions" from O'Reilly. :) The semi-short version is that: (?:a|b|c) says find a string "a" or "b" or "c", and it has to backtrack if it doesn't find it, etc, etc. in the state machine, it's 3 nodes (one for each). [abc] says find a character a, b, or c. it just accepts any of the three and moves on. in the state machine, it's a single node which accepts any of the three. The short-short version is: it's faster and it takes less memory. ;) There may be something in perlre about it too, but I haven't looked in a while. -- Randomly Generated Tagline: "Ever notice when a house burns down, the only thing left is the fireplace and the chimney?" - Bob Lazarus
pgp00000.pgp
Description: PGP signature