xsl-list
[Top] [All Lists]

Re: is there a String indexOf() function in Xpath?

2005-07-28 12:48:54
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.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--