MathGroup Archive 2006

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

Search the Archive

RE: Position

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67664] RE: [mg67639] Position
  • From: "Ingolf Dahl" <ingolf.dahl at telia.com>
  • Date: Tue, 4 Jul 2006 01:56:43 -0400 (EDT)
  • Reply-to: <ingolf.dahl at telia.com>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Bruce,
If you want the result 0 when the substring is not found, you might use 

If[# === {}, 0, #[[1, 1]]] &@ StringPosition[X, "abcd", 1]

Best regards

Ingolf Dahl

-----Original Message-----
From: Bruce Colletti [mailto:vze269bv at verizon.net] 
To: mathgroup at smc.vnet.net
Subject: [mg67664] [mg67639] Position

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"?

Presumably the command looks like Position[X,...,Heads->False], but my
attempts have come up dry.  Although StringTake[Y,4]=="abcd" would seem to
be part of the command, this fails when the string's length is less than 4.

Thankx.

Bruce

 




  • Prev by Date: Elliptic integral
  • Next by Date: Re: Position
  • Previous by thread: Re: Position
  • Next by thread: Re: Position