Previous: , Up: Regular Expressions   [Index]


8.4.1.7 Backslash Constructs

For the most part, ‘\’ followed by any character matches only that character. However, there are several exceptions: certain sequences starting with ‘\’ that have special meanings. Here is a table of the special ‘\’ constructs.

\|

an alternative

\{M\}

repeat the previous pattern exactly M times

\{M,N\}

specifies repetition

\(...\)

a grouping construct

\(?:...\)

the “shy group” (“non-capturing” or “unnumbered”) construct

\(?NUM:...\)

the “explicitly numbered group” construct

\DIGIT

matches the same text that matched DIGITth occurrence of a group

\w

matches any word-constituent character

\W

matches any character that is not a work constituent

\sCODE

matches any character whose syntax is CODE

\SCODE

matches any character whose syntax is not CODE

\cC

matches any character whose category is C. ‘M-x describe-categories

\CC

matches any character whose category is not C

The following regular expression constructs match the empty string—that is, they don’t use up any characters—but whether they match depends on the context.

\`

matches the empty string, but only at the beginning of the buffer or string being matched against.

\'

matches the empty string, but only at the end of the buffer or string being matched against.

\=

matches the empty string, but only at point.

\b

matches the empty string, but only at the beginning or end of a word.

\B

matches the empty string, but not at the beginning or end of a word, nor at the beginning or end of the buffer (or string)

\<

matches the empty string, but only at the beginning of a word.

\>

matches the empty string, but only at the end of a word.

\_<

matches the empty string, but only at the beginning of a symbol.

\_>

matches the empty string, but only at the end of a symbol.


Previous: Char Classes, Up: Regular Expressions   [Index]