If you're using XSLT 2.0, you could use the tokenize function.
Then take the length of the last string, and subtract it from the total length.
This functions runs fairly slowly, but will probably not have the overhead of the recursive templates.
If that's not an option, you could divide the string in 2 and search the last half first, then the first half; (this is another recursive template).
|