MathGroup Archive 2013

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

Search the Archive

Re: find position in a list made by string by searching incomplete string


On 4/3/13 at 10:50 PM, jougraw at gmail.com (Joug Raw) wrote:

>I have a list of strings like list1={{"a", "b    something", "a",
>"a", "b", "c", "b"} In this list, 'something' is a sting that I will
>not know in advanced and there are several spaces between the 'b'
>and the 'something' in one string. The number of the spaces is
>unknown.

>I want to find out the position of the this "b   something" sting in
>the list. So, I did,

>Position[list1, "b*"]

>and I also tried, Position[list1,"b"~~___ ]

>both of them gave me {} as results.

In[1]:= list1 = {"a", "b    something", "a", "a", "b", "c", "b"};

In[2]:= Position[Length /@ StringCases[list1, "b" ~~ __], 1]

Out[2]= {{2}}




  • Prev by Date: "Displaying" the meaning of zero
  • Next by Date: Re: Presentation/SlideShow view environment
  • Previous by thread: Re: find position in a list made by string by searching
  • Next by thread: Re: find position in a list made by string by searching incomplete string