MathGroup Archive 2006

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

Search the Archive

Re: Position

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67662] Re: Position
  • From: "J Siehler" <jsiehler at gmail.com>
  • Date: Tue, 4 Jul 2006 01:56:35 -0400 (EDT)
  • References: <e8ashi$g8j$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Bruce Colletti wrote:
> Let X be a list of strings having diverse lengths (some are the null string "").
>
> What command returns the position in X of the first element that starts with "abcd"?

Position[x, _?(StringMatchQ[#, "abcd" ~~ ___] &), Heads -> False]

If you really want only the first element, then

Position[x, _?(StringMatchQ[#, "abcd" ~~ ___] &), 1, 1, Heads -> False]


  • Prev by Date: Re: double line spacing in notebook
  • Next by Date: RE: double line spacing in notebook
  • Previous by thread: Re: Position
  • Next by thread: Re: Position