MathGroup Archive 2009

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

Search the Archive

Re: How to get position of string in a mixed list? (string pattern in

  • To: mathgroup at smc.vnet.net
  • Subject: [mg96208] Re: How to get position of string in a mixed list? (string pattern in
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Mon, 9 Feb 2009 05:35:40 -0500 (EST)
  • References: <gmndli$s1k$1@smc.vnet.net>

Position[{"a", "abc", "dfe", "nab", 1, 2, 3, {1, 2}} ,
 x_ /; StringQ[x] && StringMatchQ[x, ___ ~~ "ab" ~~ ___]]

should do the trick.

Cheers -- Sjoerd

On Feb 8, 10:00 pm, "goodh... at gmail.com" <goodh... at gmail.com> wrote:
> for list like {"a","abc","dfe","nab",1,2,3,{1,2}}, I want to get all
> strings' position in the list which match a pattern (like
> ___~~"ab"~~___). How to do it? How to use a string pattern in a list
> pattern? how to use a pattern with a condition (both list pattern&/;
> StringQ[#] and list pattern /;StringQ[]&, no working for me)
>
> Thanks.



  • Prev by Date: Something for this list
  • Next by Date: Map[] and multiple args function
  • Previous by thread: Re: How to get position of string in a mixed list? (string pattern in
  • Next by thread: Re: How to get position of string in a mixed list? (string pattern in