Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: error with regular expression within package

  • To: mathgroup at smc.vnet.net
  • Subject: [mg86599] Re: error with regular expression within package
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Fri, 14 Mar 2008 04:18:45 -0500 (EST)

On 3/13/08 at 4:31 AM, ramiro.barrantes at uvm.edu (ramiro) wrote:

>This must be very simple.  But with package below, I get the
>following error:

><< test.m Syntax::stresc: Unknown string escape \w.

>test.m:

>BeginPackage["testing`"] test::usage="test[t]" Begin["`Private`"]

>test[t_]:=StringCases[t,RegularExpression["\w+"]]

Change the above to be

test[t_]:=StringCases[t,RegularExpression["\\w+"]]

If you look at the documentation for RegularExpression you will
see all of the examples for classes of characters use a double backslash.

>End[]

>EndPackage[]



  • Prev by Date: Passing a CompiledFunction to mathlink C function
  • Next by Date: Re: Numbering graphs and tables
  • Previous by thread: Re: error with regular expression within package
  • Next by thread: question on Cases with elements that might be strings