Wolfram ResearchPRODUCTSPURCHASEFOR USERSCOMPANYOUR SITES
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.

StringReplace

StringReplace is used for substituting substrings matching the given patterns.

In[73]:= 

Out[73]=

Named patterns can be used as strings on the right-hand side of the replacement rules. Note the use of RuleDelayed () to avoid premature evaluation.

In[74]:= 

Out[74]=

When using regular expressions, it is convenient to remember that "$0" on the right-hand side refers to the whole matched substring.

In[75]:= 

Out[75]=

You can limit the number of replacements made by specifying a third argument.

In[76]:= 

Out[76]=

Note that the replacement does not have to be a string. If the result is not a string, a StringExpression is returned.

In[77]:= 

Out[77]=

In[78]:= 

Out[78]//InputForm=

There is limited support for using the old MetaCharacters option in conjunction with general string patterns, but this option is deprecated and its use should be avoided.


Any questions about topics on this page? Click here to get an individual response.Buy NowFree TrialMore Information



 © 2009 Wolfram Research, Inc.  Terms of Use  Privacy Policy |
Sign up for our newsletter: