MATLAB Programming

MATLAB Programming MATLAB Programming

cda.psych.uiuc.edu
from cda.psych.uiuc.edu More from this publisher
23.06.2015 Views

3 Basic Program Components Quantifiers (Continued) Operator expr+ q_expr* q_expr+ q_expr? Usage Match expr when it occurs 1 or more times consecutively. Equivalent to {1,}. Matchasmuchofthequantified expression as possible, where q_expr represents any of the expressions shown in the first six rows of this table. Matchasmuchofthequantified expression as possible, but do not rescan any portions of the string if the initial match fails. Matchonlyasmuchofthequantifiedexpressionas necessary. Ordinal Token Operators Operator (expr) Usage Capture in a token all characters matched by the expression within the parentheses. \N Match the N th token generated by this command. That is, use \1 to match the first token, \2 to match the second, and so on. 3-76

Regular Expressions Ordinal Token Operators (Continued) Operator Usage $N Insert the match for the N th tokeninthereplacement string. Used only by the regexprep function. If N is equal to zero, then insert the entire match in the replacement string. (?(N)s1|s2) If N th token is found, then match s1, elsematchs2 Named Token Operators Operator (?expr) \k Usage Capture in a token all characters matched by the expression within the parentheses. Assign a name to the token. Match the token referred to by name. 3-77

3 Basic Program Components<br />

Quantifiers (Continued)<br />

Operator<br />

expr+<br />

q_expr*<br />

q_expr+<br />

q_expr?<br />

Usage<br />

Match expr when it occurs 1 or more times<br />

consecutively. Equivalent to {1,}.<br />

Matchasmuchofthequantified expression as possible,<br />

where q_expr represents any of the expressions shown<br />

in the first six rows of this table.<br />

Matchasmuchofthequantified expression as possible,<br />

but do not rescan any portions of the string if the initial<br />

match fails.<br />

Matchonlyasmuchofthequantifiedexpressionas<br />

necessary.<br />

Ordinal Token Operators<br />

Operator<br />

(expr)<br />

Usage<br />

Capture in a token all characters matched by the<br />

expression within the parentheses.<br />

\N Match the N th token generated by this command. That is,<br />

use \1 to match the first token, \2 to match the second,<br />

and so on.<br />

3-76

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

Saved successfully!

Ooh no, something went wrong!