***RESOLVED: Thank you everybody for your replies/help. Also, thanks for dealing with the stupid example :P The point was understanding how the anchors and '*' were interacting, and everybody's responses helped clarify. Much obliged.***
Good Afternoon,
I'm finding myself in a semantics battle against myself, and I'm losing. I'm trully hoping somebody can smack some sense into me here.
I speak the regex
/^[a]*$/ as, "A line beginning and ending with zero or more characters in the set {a}".
With that, I understand how an empty string will match
e.g.
$foo = "";
if ($foo =~ /^[a]*$/) {
print "Match\n";
}
...prints "Match".
So, if this regex does translate to, "A line beginning and ending with zero or more letters in the set/class {a}"...then why doesn't "Match" get printed if I set
$foo = "1";
And to finalize my question (which is all about not TRULY understanding how anchors are changing the semantics), why will
$foo = "1";
if ($foo =~ /^[a]*/) {
print "Match\n";
}
.....print "Match".
What are these anchors doing in combination with the '*'?
Thanks in advance for any assistance.
Chris