MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
Metacharacter Description Example
\xN or \x{N} Character of hexadecimal value N '\x2C' matches the comma character,
defined by hex 2C.

Character Representation

Operator Description
\a Alarm (beep)
\b Backspace
\f Form feed
\n New line
\r Carriage return
\t Horizontal tab
\v Vertical tab
\char Any character with special meaning in regular expressions that you want to match
literally (for example, use \\ to match a single backslash)

Quantifiers

Quantifiers specify the number of times a pattern must occur in the matching text.

Quantifier Matches the expression when it
occurs...

Example

expr* 0 or more times consecutively. '\w*' matches a word of any length.
expr? 0 times or 1 time. '\w*(\.m)?' matches words that
optionally end with the extension .m.
expr+ 1 or more times consecutively. '<img src="\w+\.gif">' matches an
<img> HTML tag when the file name
contains one or more characters.
expr{m,n} At least m times, but no more than n
times consecutively.

{0,1} is equivalent to ?.

'\S{4,8}' matches between four and
eight non-white-space characters.

2 Program Components

Free download pdf