MathGroup Archive 2011

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

Search the Archive

Re: Using Cases or Position to Find Strings in a List of Strings

  • To: mathgroup at smc.vnet.net
  • Subject: [mg119517] Re: Using Cases or Position to Find Strings in a List of Strings
  • From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
  • Date: Tue, 7 Jun 2011 08:13:59 -0400 (EDT)

Hi,

what about using StringCases and StringPosition?

Cheers
Patrick

On Tue, 2011-06-07 at 06:48 -0400, Gregory Lypny wrote:
> Hello everyone,
> 
> I have a list of strings called myListOfFilePaths and I want to find 
> which one of those strings ends in ".DS_Store" (a hidden file created by 
> the Mac OS).  I can pick it off using Select as
> 
> 	Select[myListOfFilePaths, StringMatchQ[#, ___ ~~ ".DS_Store" ~~ 
> EndOfString] &]
> 
> but I can't do it using Cases or Position
> 
> 	Cases[myListOfFilePaths, ___ ~~ ".DS_Store" ~~ EndOfString]
> 
> 	Position[myListOfFilePaths, ___ ~~ ".DS_Store" ~~ EndOfString]
> 
> despite the fact that Head[___ ~~ ".DS_Store" ~~ EndOfString] is StringExpression.  What am I doing wrong?
> 
> 	Regards,
> 
> 	Gregory
> 




  • Prev by Date: Re: Displaying Numbers in Non-Scientific Format
  • Next by Date: Re: Using Cases or Position to Find Strings in a List of Strings
  • Previous by thread: Using Cases or Position to Find Strings in a List of Strings
  • Next by thread: Re: Using Cases or Position to Find Strings in a List of Strings