MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Using StringReplace to replace a regex containing newlines

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98221] Re: Using StringReplace to replace a regex containing newlines
  • From: dh <dh at metrohm.com>
  • Date: Fri, 3 Apr 2009 04:34:06 -0500 (EST)
  • References: <gr0gh9$94u$1@smc.vnet.net>


Hi

in Perl as well as Mathematica syntax, "." does not match newline. 

Therefore you have to specify that it should match by e.g. by using(?s). 

Here your example:



StringReplace[str,RegularExpression["BEGINIGNORE(?s).*ENDIGNORE"] -> ""]



hope thid helps, Daniel



dreeves wrote:

> Check out the following question and answer:

> 

>    http://stackoverflow.com/questions/703153/mathematica-stringreplace

> 

> It seems to me that that's a bug in Mathematica's regular expression

> engine.

> 




  • Prev by Date: Re: eliminate x
  • Next by Date: Re: Update to Hinton Button/palette tutorial for Mathematica 7?
  • Previous by thread: Using StringReplace to replace a regex containing newlines
  • Next by thread: eliminate x