Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: weird escaping problem with StringPattern inside Module[]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100824] Re: weird escaping problem with StringPattern inside Module[]
  • From: ADL <alberto.dilullo at tiscali.it>
  • Date: Mon, 15 Jun 2009 05:36:32 -0400 (EDT)
  • References: <h12ggp$edj$1@smc.vnet.net>

I would use a RegularExpression, which is not relying on any variables.
But, staying in your approach, this works as you expect:

getWeather[inputStr_String]:=
Module[{parseVars,parsePattern,abc,def},
parseVars={abc,def};
parsePattern="the "~~
    Pattern[Evaluate[parseVars[[1]]],BlankSequence[]]~~
    " in "~~
    Pattern[Evaluate[parseVars[[2]]],BlankSequence[]]~~
    " stays mainly" ->
        parseVars;
Print["patt=",parsePattern];
Flatten@StringCases[inputStr,parsePattern]
]

It is not very clean, but I hope it may help.

ADL

On Jun 14, 11:39 am, divisor <congruentialumina... at yahoo.com> wrote:
> Hello MathGroup:
>
> I am having a strange problem where my code works fine in a Notebook
> session but acts strangely inside a Module[]. I presume that this is
> some scoping problem that is currently beyond me.
>
> I know how Module[] takes local variables and adds "$nnn" or something
> to the variable. It is doing a similar thing to my string pattern and
> I have no idea how to "escape" this and disable this behavior.
>
> Any help you can provide is greatly appreciated.
>
...
>
> Regards..
>
> Roger Williams
> Franklin Laboratory



  • Prev by Date: Re: Re: How to use R within Mathematica
  • Next by Date: Re: Extracting contour values from ContourPlot
  • Previous by thread: Re: weird escaping problem with StringPattern inside Module[]
  • Next by thread: Re: weird escaping problem with StringPattern inside Module[]