23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Regular Expressions<br />

Operator<br />

(??expr)<br />

(?@cmd)<br />

(??@cmd)<br />

Usage<br />

Parse expr as a separate regular expression, and include the<br />

resulting string in the match expression. This gives you the<br />

same results as if you called regexprep inside of a regexp<br />

match expression.<br />

Execute the <strong>MATLAB</strong> command cmd, discarding any output<br />

that may be returned. This is often used for diagnosing a<br />

regular expression.<br />

Execute the <strong>MATLAB</strong> command cmd, and include the string<br />

returned by cmd in the match expression. This is a combination<br />

of the two dynamic syntaxes shown above: (??expr) and<br />

(?@cmd).<br />

<strong>MATLAB</strong> supports one type of dynamic expression for use in the replacement<br />

expression of a regexprep command. See “Dynamic Operators for the<br />

Replacement Expression” on page 3-65 for more information.<br />

Operator<br />

${cmd}<br />

Usage<br />

Execute the <strong>MATLAB</strong> command cmd, and include the string<br />

returned by cmd in the replacement expression.<br />

Example of a Dynamic Expression<br />

As an example of a dynamic expression, the following regexprep command<br />

correctly replaces the term internationalization with its abbreviated form,<br />

i18n. However, to use it on a different term such as globalization, youhave<br />

to use a different replacement expression:<br />

match_expr = '(^\w)(\w*)(\w$)';<br />

replace_expr1 = '$118$3';<br />

regexprep('internationalization', match_expr, replace_expr1)<br />

ans =<br />

i18n<br />

replace_expr2 = '$111$3';<br />

regexprep('globalization', match_expr, replace_expr2)<br />

3-59

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

Saved successfully!

Ooh no, something went wrong!