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
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
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)/
You dont need regular expressions for this:
if ($_ eq 'Joe') {
print "matched $_";
}