MathGroup Archive 2010

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

Search the Archive

Re: Trying to remove item from list of filenames

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109713] Re: Trying to remove item from list of filenames
  • From: "Nasser M. Abbasi" <nma at 12000.org>
  • Date: Thu, 13 May 2010 07:24:27 -0400 (EDT)
  • References: <hse3or$379$1@smc.vnet.net>

"Charles J. Koehler" <ckoehler5 at wi.rr.com> wrote in message 
news:hse3or$379$1 at smc.vnet.net...

>
> I read in a list of filenames from a directory, using wildcards to capture
> all the files I want to process. However, a few files make it into the 
> list
> that I don't want.  I these files have extra string of characters, that I
> should be able to remove using a regular expression and the appropriate
> Mathematica function.  Any thoughts?
>

Maybe use RegularExpression? assume you want to pick only the files with 
some extension, you can use:

In[75]:= list = {"abc1.txt", "abc2.txt", "abc3.foo"};

Select[StringCases[list, RegularExpression[".*\\.txt"]],Length[#1] > 0 & ]

Out[76]= {{abc1.txt}, {abc2.txt}}

do help on RegularExpression for more examples. You can build an RE to do 
any filtering you want. Once you got the RE correct, then the rest is easy.

--Nasser 




  • Prev by Date: Re: Trying to remove item from list of filenames
  • Next by Date: Re: Scroll content inside InputField?
  • Previous by thread: Re: Trying to remove item from list of filenames
  • Next by thread: Why do these not work?