From Second Life Wiki
Revision as of 18:42, 7 August 2007 by Kerik Rau (Talk | contribs)

Jump to: navigation, search


Function: integer llSubStringIndex( string source, string pattern );

Returns an integer that is the index of pattern in source.

• string source
• string pattern

If pattern is not found in source, -1 is returned.
The index of the first character in the string is 0


  • Performs a literal match (case sensitive).
    • Wildcards and RegEx are not supported.
All Issues ~ Search JIRA for related Bugs


Matching against last names:

        llSensorRepeat("", NULL_KEY, AGENT, PI, 96.0, 20);
    sensor(integer NumDet)
        integer i;
        //Loop through all the sensor data and match against " Linden", 
        //this causes it to match with any last name of Linden (since there can't be spaces before the firstname)
        //Alternatively you could match a firstname with "FirstName "
        for(i = 0; i < NumDet; ++i)
            if(~llSubStringIndex(llDetectedName(i), " Linden"))
                llInstantMessage(llDetectedKey(i), "Hello, I see you!");

Useful Snippets

An easy way to see if a string exists in another string...

if(~llSubStringIndex(myString, str))
{//it exists
    //This works because ~(-1) == 0 and any non-zero integer is considered true.
    //It saves bytecode and is faster then doing != -1
    //(It's also significantly less readable (unless you include the comments)
    // and most developers I know will advice against these kind of practices. -OddesE Oh)

See Also


•  llListFindList Find a list in another list

Deep Notes

Search JIRA for related Issues


function integer llSubStringIndex( string source, string pattern );