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: [mg82346] Re: [mg82267] Finds strings in a list that begin with "A"
  • From: Stern <nycstern at gmail.com>
  • Date: Thu, 18 Oct 2007 04:50:32 -0400 (EDT)
  • References: <200710170744.DAA13490@smc.vnet.net>

Here is a simple solution.

First, if you don't care about case:

Select[{"And", "Bat", "Artistic", "Cob"},
 StringMatchQ[#, RegularExpression["^[Aa].*"]] &]

Or, if you want to match to words that start with an upper case A only:

Select[{"And", "Bat", "Artistic", "Cob"},
 StringMatchQ[#, RegularExpression["^A.*"]] &]


Cheers,

Michael Stern


On 10/17/07, tomfabtastic at hotmail.com <tomfabtastic 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
>
>
>


  • Prev by Date: Re: Help with NMinimize
  • Next by Date: Re: Applying Math 6
  • 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"