MathGroup Archive 2009

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

Search the Archive

Re: When a string does not match itself

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97210] Re: When a string does not match itself
  • From: Bob F <deepyogurt at gmail.com>
  • Date: Sun, 8 Mar 2009 05:51:10 -0500 (EST)
  • References: <got8h2$go0$1@smc.vnet.net>

On Mar 7, 12:42 am, <ingolf.d... at telia.com> wrote:
> This is a maybe a trivial question, but I have not found the explanation =
in
> help (I am using Mathematica 7.0.0):
>
> Normally a string matches itself:
>
> In[270]:= StringMatchQ["monkey", "monkey"]  
>
> Out[270]= True
>
> But
>
> In[271]:= StringMatchQ["\\*", "\\*"]  
>
> Out[271]= False
>
> Why? Compare also to
>
> In[4]:= StringCases["\\*", "\\*"]  
>
> Out[4]= {"\\*"}
>
> In[267]:= StringPosition["\\*", "\\*"]  
>
> Out[267]= {{1, 2}}
>
> Best regards
>
> Ingolf Dahl
>
> Sweden
>
> ingolf.d... at telia.com

The second argument to StringMatchQ[] is a "pattern" and the first
argument is a string, so if you wanted to you could

   StringMatchQ["*", "\\*"]

and you would get a value of True back. Look over the documentation of
StringMatchQ[] and "String Patterns" guide and tutorial for more info.

-Bob


  • Prev by Date: Re: Wolfram/Alpha
  • Next by Date: Re: typsetting bug still present in Mathematica 7.01
  • Previous by thread: Re: When a string does not match itself
  • Next by thread: Re: When a string does not match itself