Re: When a string does not match itself
- To: mathgroup at smc.vnet.net
- Subject: [mg97224] Re: When a string does not match itself
- From: dbreiss at gmail.com
- Date: Sun, 8 Mar 2009 05:53:50 -0500 (EST)
- References: <got8h2$go0$1@smc.vnet.net>
You have to escape both the \ and the * as in StringMatchQ["\\\*", "\\\*"] since both are special characters.... On Mar 7, 2: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