MathGroup Archive 2007

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

Search the Archive

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


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"