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
>
>
>
- References:
- Finds strings in a list that begin with "A"
- From: tomfabtastic@hotmail.com
- Finds strings in a list that begin with "A"