|
NAME
escapes — when and how to use an escape character
SYNTAX
\
DESCRIPTION
Several terms and symbols in the Cobra query language have a special meaning, depending on
where they appear in a command or query.
This special meaning can be suppressed by preceding the term or symbol with
a single backward slash escape character: \.
Below we'll discuss typical uses, depending on context.
- In mark expressions.
Use an escape character to pass through the next character
uninterpreted. An example can be when a space character
is part of a file name. We can
match the file name in an expression by escaping the space,
e.g.: m & (.fnm == cobra\ file.c)
- For qualifiers following a
mark,
contains, or
stretch command.
Use an escape character to suppress the interpretation of an argument
as a qualifier, e.g.: mark \no to mark the literal text no
(and similar for other qualifiers ir, top, and &).
- To match on a literal semi-colon, avoiding that it is interpreted as a
command separator, e.g.: m \;.
- To match on a literal sharp symbol, avoiding its interpretation as a comment
delimiter in cobra queries (not in cobra programs), e.g.: m \#define.
- To match a space or tab character anywhere in the argument list of a query or command,
precede the character with the escape character.
- To match a string that starts with a forward slash character, to avoid
that it is interpreted as a regular expression, e.g.: m \/foo.
Similarly to match a regular expression that contains a space, e.g.:
m /foo\ bar.
- To match a string that starts with a @ or $ symbol, to avoid its interpretation
as a meta character, e.g.: \@ident, or \$$.
- To match tokens that contain the literal text \\: m /\\\\.
Note that each of the backslashes needs to be escaped here, given a total
of four backslashes to match two in the source text.
- In inline programs (i.e., in between the delimiters %{ and %}).
- in strings:
\n and \t are replaced with the corresponding
ascii codes so that print statements have the desired effect:
print "\n";. To prevent the match, use an additional
escape: print "\\n";.
- elswhere in a cobra program \ characters are stripped and
the next character is preserved as a literal character, no matter what it is.
SEE ALSO
qualifiers
|
|