[Chicago-talk] help with Reg Exp, pls...

Randal L. Schwartz merlyn at stonehenge.com
Mon Dec 15 12:41:06 CST 2003

>>>>> "Walter" == Walter Torres <walter at torres.ws> writes:

Walter> All I want to know is if the string given passes or fails a test that can
Walter> handle the examples below...

Walter>    Dr. Roger O'Malley
Walter>    Mrs. Sara Harris-Henderson
Walter>    Manuel Gonzalez
Walter>    Forsok Bokstaver
Walter>    Contem Espaco-Valido

    $ perl
    my $regex = '^('. join("|", map quotemeta $_, split "\n", <<'END'). ')$';
    Dr. Roger O'Malley
    Mrs. Sara Harris-Henderson
    Manuel Gonzalez
    Forsok Bokstaver
    Contem Espaco-Valido
    print $regex, "\n";
    ^(Dr\.\ Roger\ O\'Malley|Mrs\.\ Sara\ Harris\-Henderson|Manuel\ Gonzalez|Forsok\ Bokstaver|Contem\ Espaco\-Valido)$

Somehow, I don't think you mean that.  What *do* you mean?

Creating a regex by example is almost always the wrong way.  Give us rules.

And, for any rule that you come up with about a name, I bet I can find
a name that violates the rule.  So the real question is, why do you care?

Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

More information about the Chicago-talk mailing list