Programming Previous page   Next Page

Character Representation

The following character combinations represent specific character and numeric values.

Operator
Usage
\a
Alarm (beep)
\b
Backspace
\e
Escape
\f
Form feed
\n
New line
\r
Carriage return
\t
Horizontal tab
\v
Vertical tab
\oN or \o{N}
Character of octal value N
\xN or \x{N}
Character of hexadecimal value N
\char
If a character has special meaning in a regular expression, precede it with backslash (\) to match it literally.

Octal and Hexadecimal -- \o, \x

Use \x and \o in an expression to find a comma (hex 2C) followed by a space (octal 40) followed by the character 2:

Special Characters -- \char

Use \ before a character that has a special meaning to the regular expression functions if you want that character to be interpreted literally. The intention in this example is to have the string '(ab[XY|Z]c)' interpreted literally. The first expression does not do that because regexp interprets the parentheses and | sign as the special characters for grouping and logical OR:

This next expression uses a \ before any special characters. As a result the entire string is matched:


Previous page  Character Classes Logical Operators Next page

© 1994-2005 The MathWorks, Inc.