Subject: Re: is there a String indexOf() function in Xpath?
From: Arian Hojat <arianhojat2000@xxxxxxxxx>
Date: Thu, 28 Jul 2005 12:55:54 -0700 (PDT)
|
Yes this was what i was looking for :)
With so many functions in xpath 2.0, I was just hoping
it was in there somewhere. oh well, I'll stick to your
approach.
Thanx again!
Arian
--- Jon Gorman <jonathan.gorman@xxxxxxxxx> wrote:
> > Want to do something like this...
> > substring($titleText,
> > indexOf($titleText, ' findThisTextsIndex ')+5 ,
> > indexOf($titleText, 'toHere') )
> >
>
> An index of function would be nice, but it's not
> clear it's needed.
> Perhaps a description of your problem would be more
> helpful then what
> you are trying to do. In any case, I'll give it a
> stab below.
>
>
> Why not just do some combination of substring,
> substring-before and
> substring-after?
>
> I'm going to create an entirely fictional example
>
> I have some string of characters that contain two
> indicators of a
> special sequence of text, START and END. In
> addition, there are
> always five characters after START that are always
> the same. (It may
> be you're using the +5 to try to avoid the starting
> characters, but
> who knows since you didn't give us that
> information.)
>
> Example string: It was a dark and stormy night
> START00123Needs a
> little more punch, how about it was a very, very
> dark and very, very
> stormy nightEND which would be the night of a
> most...
>
> substring-after(TheString,"START")
>
> gives us everything after START ie
>
> 00123Needs a little more punch, how about it was a
> very, very dark and
> very, very stormy nightEND which would be the night
> of a most...
>
>
> substring(substring-after(TheString,"START"),6)
> gives us the string starting with the 6th character
> after START
>
> Needs a little more punch, how about it was a very,
> very dark and
> very, very stormy nightEND which would be the night
> of a most...
>
>
>
>
substring-before(substring(substring-after(TheString,"START"),6),"END")
> gives us the string starting with the 6th charcter
> after START but before END
>
> Needs a little more punch, how about it was a very,
> very dark and
> very, very stormy night
>
>
> Is that something like what you're looking for?
>
>
>
> Jon Gorman
> ps. Feels like I'm abusing substring-after and
> substring-before
> lately and it's been a while since I've even used
> them in my own code.
>
>
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
|