Difference between revisions of "LlSubStringIndex"

From Second Life Wiki
Jump to navigation Jump to search
Line 11: Line 11:
|constants
|constants
|examples
|examples
|helpers
|helpers=
An easy way to see if a string exists in another string...
<pre>
if(~llSubStringIndex(myString, str))
{//it exists
    //This works because ~(-1) == 0
    //It saves bytecode and is faster then doing == -1
}
</pre>
|also_functions=
|also_functions=
{{LSL DefineRow||[[llListFindList]]|Find a list in another list}}
{{LSL DefineRow||[[llListFindList]]|Find a list in another list}}

Revision as of 07:04, 29 March 2007

Summary

Function: integer llSubStringIndex( string source, string pattern );
0.0 Forced Delay
10.0 Energy

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

• string source
• string pattern

If pattern is not found in source, -1 is returned.

Caveats

  • Performs a literal match.
    • Wildcards and RegEx are not supported.

Examples

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
    //It saves bytecode and is faster then doing == -1
}

See Also

Functions

•  llListFindList Find a list in another list

Deep Notes

Signature

function integer llSubStringIndex( string source, string pattern );