I am just learning perl and doing some practicing and exploring.
I am trying to write a regular expression that will print only values that start with a 'b' have an 'a' in the middle anywhere and end in an 'n'.
Currently the regex works except for some reason it will also print out the word aban.
here is my code:
@words = qw (brandon Brandon band banana ban aban);
foreach $word (@words)
{
if($word =~ /^b*\w*a*\w*n$/)
{
print "$word\n";
}
}
currently it prints out the following:
brandon
Brandon
ban
aban
Why is it printing aban when i use the ^b to specify starting with b?
I am trying to write a regular expression that will print only values that start with a 'b' have an 'a' in the middle anywhere and end in an 'n'.
Currently the regex works except for some reason it will also print out the word aban.
here is my code:
@words = qw (brandon Brandon band banana ban aban);
foreach $word (@words)
{
if($word =~ /^b*\w*a*\w*n$/)
{
print "$word\n";
}
}
currently it prints out the following:
brandon
Brandon
ban
aban
Why is it printing aban when i use the ^b to specify starting with b?