Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

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

Search the Archive

Re: Finds strings in a list that begin with "A"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg82370] Re: Finds strings in a list that begin with "A"
  • From: Peter <petsie63 at googlemail.com>
  • Date: Thu, 18 Oct 2007 05:02:49 -0400 (EDT)
  • References: <ff4egn$d6p$1@smc.vnet.net>

On Oct 17, 9:44 am, tomfabtas... at hotmail.com wrote:
> Hello,
>
> I am trying to look through a list of strings and return all strings
> that start with an "A".
>
> For example, my list could be :
>
> {"And", "Bat", "Artistic", "Cob"} so I want to return {"And",
> "Artistic"}.
>
> Any ideas ?
>
> Thanks,
> Tom

Hi Tom,

two possibilities are:

In[1]:=
Flatten[StringCases[{"And", "Bat", "Artistic", "Cob"},
StringExpression["A", ___]], 1]
Out[1]=
{"And", "Artistic"}

In[2]:=
Pick[#1, StringTake[#1, 1], "A"]&[{"And", "Bat", "Artistic", "Cob"}]
Out[2]=
{"And", "Artistic"}

Peter



  • Prev by Date: Re: Recursion limit: a good idea to ignore?
  • Next by Date: ListLinePlot[] inside a loop
  • Previous by thread: Re: Finds strings in a list that begin with "A"
  • Next by thread: Re: Finds strings in a list that begin with "A"