Difference between revisions of "LlSubStringIndex"

From Second Life Wiki
Jump to navigation Jump to search
m
Line 3: Line 3:
|func=llSubStringIndex
|func=llSubStringIndex
|return_type=integer|p1_type=string|p1_name=source|p2_type=string|p2_name=pattern
|return_type=integer|p1_type=string|p1_name=source|p2_type=string|p2_name=pattern
|func_footnote=If '''pattern''' is not found in '''source''', {{HoverText|-1|negative one, 0x{{LSL_Hex/Write|-1}}}} is returned.
|func_footnote=If '''pattern''' is not found in '''source''', {{HoverText|-1|negative one, 0x{{LSL_Hex/Write|-1}}}} is returned.<br/>
The index of the first character in the string is {{HoverText|0|zero}}
|func_desc
|func_desc
|return_text=that is the index of '''source''' in '''pattern'''.
|return_text=that is the index of '''source''' in '''pattern'''.

Revision as of 14:55, 5 June 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.
The index of the first character in the string is 0

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
    //(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

Functions

•  llListFindList Find a list in another list

Deep Notes

Signature

function integer llSubStringIndex( string source, string pattern );