^
is the beginning-of-line anchor, so it will be a "zero-width match," meaning it won't match any actual characters (and the first character matched after the ^
will be the first character of the string). Similarly, $
is the end-of-line anchor.
*
is a quantifier. It will not by itself match anything; it only indicates how many times a portion of the pattern can be matched. Specifically, it indicates that the previous "atom" (that is, the previous character or the previous parenthesized sub-pattern) can match any number of times.
To actually match some set of characters, you need to use a character class. As RichieHindle pointed out, the character class you need here is .
, which represents any character except newlines (and it can be made to match newlines as well using the appropriate flag). So .*
represents *
(any number) matches on .
(any character). Similarly, .+
represents +
(at least one) matches on .
(any character).