|Top Previous Next|
Scripts > Token definitions > Regular expressions > Anchors
Warning: Anchors only have an effect if the expression is target of a Skip node and the effect of anchors depends on the ignorable characters set in the project options.
An anchor is something that matches the null string at special text positions.
'^' matches the null string at the start of a line, when used as the first character of an expression, or the first character of a sub-expression.
'$' matches the null string at the end of a line, when used as the last character of an expression, or the last character of a sub-expression.
"\<" matches the null string at the start of a word.
"\>" matches the null string at the end of the word.
"\b" matches the null string at either the start or the end of a word.
"\B" matches a null string within a word.
"\`" matches the start of a buffer.
"\A" matches the start of the buffer.
"\'" matches the end of a buffer.
"\z" matches the end of a buffer.
"\Z" matches the end of a buffer, or possibly one or more new line characters followed by the end of the buffer.
A buffer is considered to consist of the whole sequence passed to the matching algorithms.
In the TextTransformer "\A" precedes all regular expressions - when not used inside a SKIP definition - to assert, that the next match will begin at the current text position. So an anchor like "^" has no use. The search begins at the beginning of the actual buffer and the regular expression "does not know" where the buffer begins in the text.
But for SKIP nodes the use of an anchor "^" can make sense:
If a token is defined as:
LINE_START_WORD = ^\w+
and the grammar defines a SKIP symbol:
the first line of the following text will be skipped:
" Wort1 not at line begin
Wort2 at line begin"
"Wort2" will be recognized as LINE_START_WORD.
This page belongs to the TextTransformer Documentation
|Home Content German|