Anchors

So far every regex could match anywhere within a string. Often it is useful to limit the match to the start or end of a string or line or to word boundaries. A single caret ^ anchors the regex to the start of the string and a dollar sign $ to the end. m/ ^a / matches strings beginning with an a, and m/ ^ a $ / matches strings that consist only of an a.

Таблица 9.2. Regex anchors

AnchorMeaning
^start of string
$end of string
^^start of a line
$$end of a line
<< left word boundary
«left word boundary
> >right word boundary
»right word boundary