Confused by the basic regular expression operation

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   
+4
6

"" Matches the **preceding** element zero or more times. " " " ", " " ( " " ).

+2

:

.{2,4}

:

(..)|(...)|(....)

:

.*

:

()|(.)|(..)|(...)| // etc.
+2

. . "a" "abc", "b".

+2

* - , " ". ; ..

, (A|B)*, A B, ; A B, "".

+1

. , . , , , - ( , , )). , , 0 any type of character at all, , , .

+1

.

* ( ) 0 .

:

means ., not the match of the previous character. This has nothing to do with previous matches. It only repeats point 0 or more times.

It is like recording .?.?and an infinite amount of time.

+1
source

Source: https://habr.com/ru/post/1525927/


All Articles