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 Exact, Minimum, and Maximum Quantities — {min,max} Use {m}, {m,}, and{m,n} to verify the href syntax used in HTML. This statement requires the href to have at least one non-whitespace character, followed by exactly one occurrence of .html, optionally followed by # and five to eight digits: hstr = ''; expr = '

Regular Expressions This section covers • “Operators Used with Tokens” on page 3-49 • “Introduction to Using Tokens” on page 3-49 • “Using Tokens — Example 1” on page 3-50 • “Using Tokens — Example 2” on page 3-51 • “TokensThatAreNotMatched”onpage3-52 • “Using Tokens in a Replacement String” on page 3-53 Operators Used with Tokens Here are the operators you can use with tokens in MATLAB. 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. $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 Introduction to Using Tokens You can turn any pattern being matched into a token by enclosing the pattern in parentheses within the expression. For example, to create a token for a dollar amount, you could use ’(\$\d+)’. Each token in the expression is assigned a number, starting from 1, going from left to right. To make a reference to a token later in the expression, refer to it using a backslash followed by the token number. For example, when referencing a token generated by the third set of parentheses in the expression, use \3. 3-49

3 Basic Program Components<br />

Exact, Minimum, and Maximum Quantities — {min,max}<br />

Use {m}, {m,}, and{m,n} to verify the href syntax used in HTML. This<br />

statement requires the href to have at least one non-whitespace character,<br />

followed by exactly one occurrence of .html, optionally followed by # and<br />

five to eight digits:<br />

hstr = '';<br />

expr = '

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

Saved successfully!

Ooh no, something went wrong!