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


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