in reply to Regex Semantics
/^[a]*$/ matches a string containing 0 or more 'a' characters which may be followed by a new line character.
Note that the character class is redundant. It could equally well be written /^a*$/.
Consider:
use strict; use warnings; my @strings = ('', '1', 'a', "a\n"); /^[a]*$/ && print "/^[a]*\$/ matches >$_<\n" for @strings; /^a*$/ && print "/^a*\$/ matches >$_<\n" for @strings;
Prints:
/^[a]*$/ matches >< /^[a]*$/ matches >a< /^[a]*$/ matches >a < /^a*$/ matches >< /^a*$/ matches >a< /^a*$/ matches >a <
|
|---|