Sep
6
Perl Regex - Find Repeated Words
September 6, 2008 |
You can use this recipe to find words that appear more than one time in sequence, such as the the.
#!/usr/bin/perl -w
use strict;
my $mystr = $ARGV[0] || die "You must supply a parameter!\n";
if ( $mystr =~ /\b(\w+)\s\1\b/ )
{
print "I think I'm seeing double.\n";
}
else
{
print "Looks okay to me.\n";
}
Similar Posts


















