[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
13.2.11 Cloisters
The location between the ?
and the :
of a non-capturing
cluster is called a cloister.(8) You can put modifiers there
that will cause the enclustered subpattern to be treated specially. The
modifier i
causes the subpattern to match
case-insensitively:
(pregexp-match "(?i:hearth)" "HeartH") ⇒ ("HeartH")
The modifier x
causes the subpattern to match
space-insensitively, ie, spaces and
comments within the
subpattern are ignored. Comments are introduced
as usual with a semicolon (;
) and extend till
the end of the line. If you need
to include a literal space or semicolon in
a space-insensitized subpattern, escape it
with a backslash.
(pregexp-match "(?x: a lot)" "alot") ⇒ ("alot") (pregexp-match "(?x: a \\ lot)" "a lot") ⇒ ("a lot") (pregexp-match "(?x: a \\ man \\; \\ # ignore a \\ plan \\; \\ # me a \\ canal # completely )" "a man; a plan; a canal") ⇒ ("a man; a plan; a canal")
You can put more than one modifier in the cloister.
(pregexp-match "(?ix: a \\ man \\; \\ # ignore a \\ plan \\; \\ # me a \\ canal # completely )" "A Man; a Plan; a Canal") ⇒ ("A Man; a Plan; a Canal")
A minus sign before a modifier inverts its meaning.
Thus, you can use -i
and -x
in a
subcluster to overturn the insensitivities caused by an
enclosing cluster.
(pregexp-match "(?i:the (?-i:TeX)book)" "The TeXbook") ⇒ ("The TeXbook")
This regexp will allow any casing for the
and book
but insists that TeX
not be
differently cased.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 31, 2014 using texi2html 5.0.