Re: Find Elements Containing "r"
- To: mathgroup at smc.vnet.net
- Subject: [mg42534] Re: Find Elements Containing "r"
- From: Bill Rowe <bjrowe at earthlink.net>
- Date: Sat, 12 Jul 2003 20:53:14 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 7/12/03 at 5:19 AM, oldwhitecar at hotmail.com (Allan de Frates) wrote: > How do I find all the elements of a list that contain the letter "r" or some > other text pattern? For example, if the list is {ar1, ar2, ab1, ab2, rab, > ab3} and I wanted element matching "r", the result would be {ar1, ar2, rab}. > There has to be a simple way to do this, but I'm stumped. Try In[1]:= lst={ar1,ar2,ab1,ab2,rab,ab3}; Select[lst,StringMatchQ[ToString@#,"*r*"]&] Out[2]= {ar1, ar2, rab}