The documentation for Rust regexes claims the following:
Notice the use of the
^
and$
anchors. In this crate, every expression is executed with an implicit .*? at the beginning and end, which allows it to match anywhere in the text. Anchors can be used to ensure that the full text matches an expression.
What does this mean exactly? I get that having .*?
at the beginning and end means that if there is a match in the text, it will match no matter where it is (which is not what I want when constructing a lexer), but how do the anchors ^
and $
fit into all this?
Does placing a ^
at the start of the string allow me to only search at the very beginning of the string? How about $
, does it match only at the very end of the input? In other words, does placing these anchors disable the implicit .*?
s?