Stristr
De DigiWiki.
Example:
This example uses its basic feature, to provide the content left, or right of the searched string.
default { touch_start(integer total_number) { string source = "Hello there, Ugleh is my name!"; string mess = stristr(source,"Ugleh",TRUE); //True means after Needle llOwnerSay(mess);//outputs " is my name!" mess = stristr(source,"Ugleh",FALSE); //False means before Needle. llOwnerSay(mess);//outputs "Hello there, " } }
Specification:
// Function created by Ugleh Ulrik string stristr(string haystack, string needle, integer after_needle){ if(haystack) {//we have a haystack, it's not "" //Now find us a needle! integer pos = llSubStringIndex(haystack, needle); if(~pos) {//We have found a needle! if(after_needle)//return what comes after needle return llGetSubString(haystack, pos + llStringLength(needle), -1); return llDeleteSubString(haystack, pos, -1); } } return ""; }