I want match开发者_运维问答
my @array = ( 'Tree' , 'JoeTree','Joe');
foreach (@array ) {
if ( $_ =~ /^(Joe)[^Tree]/gi) {
print "matched $_";
}
}
It matching only Joe. it should not matching anything else
You dont need regular expressions for this:
if ($_ eq 'Joe') {
print "matched $_";
}
Match only 'Joe' as the whole text?
/^(Joe)$/
or match 'Joe' as the word alone?
/\b(Joe)\b/
or match 'Joe' not followed by 'Tree'?
/^(Joe)(?!Tree)/
精彩评论