Re: StringMatchQ and Regular Expressions
- To: mathgroup at smc.vnet.net
- Subject: [mg88408] Re: StringMatchQ and Regular Expressions
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Mon, 5 May 2008 06:09:24 -0400 (EDT)
- References: <fvhdu8$3p6$1@smc.vnet.net>
Mark Westwood wrote:
> Hi
>
> I'm running Mathematica v6.0.2 on Windows XP.
>
> I define a regex thus:
>
> doStmt = RegularExpression["do(?=\\s*\\w+=)"];
>
> and then execute:
>
> StringCases["doindex= ", doStmt]
>
> which brings the response
>
> {do}
>
> I then execute
>
> StringMatchQ["doindex= ", doStmt]
>
> which brings the response
>
> False
>
> I had expected that if StringCases found any cases, then StringMatchQ
> would return True. Obviously this is not the case, but can anyone out
> there throw light upon this.
>
> Thanks for any insights you can give me
>
> Mark Westwood
>
StringMatchQ returns true if the WHOLE string matches the given pattern
- not just part of it.
David Bailey
http://www.dbaileyconsultancy.co.uk