Re: StringCases matching on portions of sublist?
- To: mathgroup at smc.vnet.net
- Subject: [mg106687] Re: StringCases matching on portions of sublist?
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Thu, 21 Jan 2010 04:52:10 -0500 (EST)
- References: <hj6qfm$8rk$1@smc.vnet.net>
Am 20.01.2010 12:47, schrieb Jason Ledbetter: > Folk, > > I'm trying to write a function to narrow down some data by timestamp but I'm > having some trouble getting this to work. > > My data is a list of lists with the first member of each sublist being a > date stamp. I was hoping to use StringCases to match but I'm apparently > missing something here. > > Example data is as follows: > > z={{"Thu Nov 19 12:09:23 GMT 2009", 7492, 0, > 0}, {"Thu Jan 07 13:48:21 GMT 2010", 9225, 3, > 0}, {"Thu Dec 17 09:30:52 GMT 2009", 8735, 1, 0}} > > > I've tried the following: > > > StringCases[z, {"*Nov",___}] > > > which returns: > > > String or list of strings expected at position 1 in StringCases. This makes > sense to me.. so I tried: > > > StringCases[z[[All,1]], ___~~Nov~~___] > > > which returns: > > > {{"Thu Nov 19 12:09:23 GMT 2009"}, {}, {}} > > > How can this be modified to return the full sublist where the first element > of the sublist matches a string pattern? maybe: Pick[z, StringMatchQ[z[[All, 1]], ___ ~~ "Nov" ~~ ___]] hth, albert