Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #3001

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

From Patrick Scheibe <pscheibe@trm.uni-leipzig.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Using Cases or Position to Find Strings in a List of Strings
Date 2011-06-07 12:13 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <isl4m3$7mb$1@smc.vnet.net> (permalink)

Show all headers | View raw


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
> 


Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Using Cases or Position to Find Strings in a List of Strings Patrick Scheibe <pscheibe@trm.uni-leipzig.de> - 2011-06-07 12:13 +0000

csiph-web