[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] What is regex



> >A RegEx (RE or regular expression) is the ability of a
> >language (say perl for example) to shorten what
> >would be a usually much longer string manipulation
> >command into short 'equations', so to speak.
> 
> And... (thusly) a regex often forms the basis of _many_ of the really 
> cool and esoteric tricks one can play with Perl.

That could be misleading. A regular expression is a *description of
a string*. And it is new functionality for all practical purposes
(unless you mean it shortens the "work" of implementing all of RE
in Perl).

As for tricks, here's one--pretty old and nothing very special--
but it might be new to someone:

    ($_, $p) = ("*", " " x shift);
    while (chop $p) {
        s/(.) /$1$1/g; s/^|$/ /g; s/(.)(.)/$1 eq $2?"  ":"* "/eg;
        print "$p$_\n";
    }                            

--
Tushar Samant
~
~
:wq


==== Want to unsubscribe from this list? (Don't you love us anymore?)
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org