23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Regular Expressions<br />

There is an additional qualifier named 'once' that you can use to return<br />

only the first match found.<br />

Elements of an Expression<br />

Tables and examples in the sections that follow show the metacharacters<br />

and syntax supported by the regexp, regexpi, andregexprep functions in<br />

<strong>MATLAB</strong>. Expressions shown in the left column have special meaning and<br />

match one or more characters according to the usage described in the right<br />

column. Any character not having a special meaning, for example, any<br />

alphabetic character, matches that same character literally. To force one of<br />

the regular expression functions to interpret a sequence of characters literally<br />

(ratherthanasanoperator)usetheregexptranslate function.<br />

These elements are presented under these categories:<br />

• “Character Classes” on page 3-33<br />

• “Character Representation” on page 3-36<br />

• “Grouping Operators” on page 3-37<br />

• “Nonmatching Operators” on page 3-39<br />

• “Positional Operators” on page 3-40<br />

• “Lookaround Operators” on page 3-41<br />

• “Quantifiers” on page 3-45<br />

• “Tokens” on page 3-48<br />

• “Named Capture” on page 3-53<br />

• “Conditional Expressions” on page 3-55<br />

• “Dynamic Regular Expressions” on page 3-58<br />

Each table is followed by a set of examples that show how to use the syntax<br />

presented in that table.<br />

Character Classes<br />

Character classes represent either a specific set of characters (e.g., uppercase)<br />

or a certain type of character (e.g., non-whitespace).<br />

3-33

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!