Consider the following AS_PATH filter:
ip as-path access-list 20 permit 850
This filter matches any AS_PATH that includes the string 850. Examples of matching AS_PATHs are ( 850 ), (23, 5, 850, 155), and (3568, 5 850, 310). A match is found whether the string is alone in the attribute, one of several AS numbers in the attribute, or even a part of a larger AS number in the attribute.
Suppose, however, that you want to match only an AS_PATH that contains the single AS number 850. For this, you must be able to delineate the beginning and end of a line. A caret (^) matches the beginning of a line, and a dollar sign ($) matches the end of a line. So,
ip as-path access-list 20 permit ^850 $
tells the regex to match the beginning of the line, followed immediately by the string 850, followed immediately by the end of the line.
You also can use the two metacharacters to match an empty AS_PATH:
ip as-path access-list 21 permit ^$
In this case, the regex matches the beginning of a line followed immediately by the end of the line; if any other characters exist between the beginning and end of the line, no match is made.