I have a pretty simple question about regular expressions. I use an expression .*without thinking that it matches the expectation of a match, for example. to the end of the line. It works.
But for some reason I started thinking about this expression. Wikipedia Check (my emphasis)
. Matches any single character
* Matches the **preceding** element zero or more times
So now, according to this definition, why is it .*not trying to match the first character in a string 0 or more times, but instead trying to apply a match to each in the string?
I mean, if I have abc, should he try to fit a,aa,aaa etccorrectly?
But this is not so:
~
$ perl -e '
> my $var="abcdefg";
> $var =~ /(.*)/;
> print "$1\n";'
abcdefg