Don't click here unless you want to be banned.

LSL Wiki : llSubStringIndex

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org
integer llSubStringIndex(string source, string pattern)

Returns the index in source where pattern first appears. Returns -1 if no match is found.

Remember, strings (and lists) are indexed starting from 0.

This function is relatively slow. Performs a literal match (case sensitive).

Example:
string sentence = "This sentence has a verb.";

llSay(0, (string)llSubStringIndex(sentence, "e")); // 6
llSay(0, (string)llSubStringIndex(sentence, "u")); // -1
llSay(0, (string)llSubStringIndex(sentence, "ten")); // 8

Q: "Relatively slow?" How exactly does this differ from the rest of LSL? :) -?
A: Actually, the execution of LSL functions themselves is quite fast, unless they have a built-in delay, as in the case of llInstantMessage, for example. The slow part (because of little allocation of timeslices because of the huge number of scripts a simulator runs in parallel) is the execution of the script's bytecode itself (loops, math, moving data in memory, etc.). So, unlike others functions, llSubStringIndex is likely simply slow in its execution, though it's possible that the slowness is due to an unknown built-in delay.
A2: In my own tests, this function performed 4.3 times slower than llGetSubString, completing 100 iterations in an average of 2.2 seconds on an open space sim versus 0.51 seconds. However, llDeleteSubString appears to perform even slower than this function, completing 100 iterations in an average of 2.3 seconds.

Compare with llListFindList.


This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | String
There are 7 comments on this page. [Display comments/form]