Thomas Bätzler wrote:
Andrew Gaffney <[EMAIL PROTECTED]> wrote:
Too literally. Basically, I'm trying to match a word that
contains a mix of >=2 numbers (possibly next to each other)
and letters. My current regex is:
\b\d*[a-zA-Z]*(\d+[a-zA-Z]+)+\d*[a-zA-Z]*[^:,]\b
but that seems to catch too much.
Ever considered doing this w/o a regex? Maybe it would be
easier to split the text into words first, and then count
letters and numbers using tr//, like
#!/usr/bin/perl -w
sub badword {
my $word = shift;
return $word =~ tr/a-zA-Z/ / >= 2 && $word =~ tr/0-9/ / >= 2;
}
my $text = 'I confess to 0wn1ng the email address [EMAIL PROTECTED]';
foreach my $word (split /\s+/, $text){
print "bad: $word\n" if badword( $word );
}
__END__
Thanks. That's an interesting solution.
--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>