Re: Find Elements Containing "r"
- To: mathgroup at smc.vnet.net
- Subject: [mg42528] Re: [mg42520] Find Elements Containing "r"
- From: Andrzej Kozlowski <andrzej at lineone.net>
- Date: Sat, 12 Jul 2003 20:53:07 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On Saturday, July 12, 2003, at 10:19 AM, 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. > > Allan de Frates > > > > > In fact there are several simple ways, one of them being: Select[{ar1, ar2, ab1, ab2, rab, ab3},StringMatchQ[ToString[#],"*r*"]&] Out[4]= {ar1,ar2,rab} Andrzej Kozlowski