contents.gifprev1.gifnext1.gif

ANCHOR

Anchor is search keyword

When used in a pattern, ANCHOR causes a search to try to match the pattern following ANCHOR starting at the current character position. If the match does not occur immediately, the search does not skip over characters looking for a match.

ANCHOR is a keyword, not a built-in, and has no parameters.

ANCHOR is a keyword that, when used with SEARCH or SEARCH_ QUIETLY, requires a match of the next pattern element at the current search position or the search will fail. If there is no match, the search will fail rather than move its starting point. Normally the first element of a pattern is unanchored and all subsequent elements are anchored. This allows the first element of the search pattern to be located anywhere throughout the buffer text and the remainder of the pattern elements to follow directly behind.

Example:

To illustrate the effect of anchoring a pattern, we will first show an unanchored pattern.

ANY$ABC := “ABC”;

A search for pattern ANY$ABC would continue to the next character if the current search location was not at string “ABC”.

ABC$NOW := ANCHOR + “ABC”;

Searching for the anchored “ABC” string requires that a match be found at the current search location or the search will fail.

Related Builtins:

SEARCH

SEARCH_QUIETLY

UNANCHOR