[Chicago-talk] help with Reg Exp, pls...
lembark at wrkhors.com
Mon Dec 15 17:15:17 CST 2003
-- Walter Torres <walter at torres.ws>
> I've been pulling my hair out on this.
> I can't get a regExp to valid any of these names.
> All I want to know is if the string given passes or fails a test that can
> handle the examples below...
> Dr. Roger O'Malley
> Mrs. Sara Harris-Henderson
> Manuel Gonzalez
> Forsok Bokstaver
> Contem Espaco-Valido
> Any ideas?
Not really sure what you are asking for. "a test" could mean
nearly anything, for example:
if( /\S+/ )
# the thing has non blanks?
Do you know the names in advance? If so then something like:
# read in the names, chomp them, whatever.
my @namz = whatever;
$_ = qr/$_/ for @namz;
# check for the names in your input:
while( <ARGV> )
for my $rx ( @namz )
handle_a_matched_name $_ if /$rx/;
print STDERR "No match: $_";
converting the string to compiled regexen saves some time
on the iteration.
Steven Lembark 2930 W. Palmer
Workhorse Computing Chicago, IL 60647
+1 888 359 3508
More information about the Chicago-talk