Difference between revisions of "Left"
Jump to navigation
Jump to search
m (added to Category:LSL String) |
(Undo revision 1142069 by Opensource Obscure (Talk) + string) |
||
Line 1: | Line 1: | ||
{{ | {{LSL_Function | ||
|mode=user | |||
== | |func=left | ||
|p1_type=string|p1_name=src | |||
Returns text left of a specified separator | |p2_type=string|p2_name=divider | ||
|return_type=string | |||
|return_text=that is the text in '''src''' that is left of the first occurrence of '''divider'''. | |||
|func_desc=Returns text left of a specified separator | |||
|func_footnote= | |||
If '''divider''' is not found then '''src''' is returned in it's entirety. | |||
See also: [[Right]] | See also: [[Right]] | ||
|examples= | |||
<lsl>string value = left("Colour=Brown", "="); //value == "Colour"</lsl> | |||
|spec=<lsl>string left(string src, string divider) { | |||
string | integer index = llSubStringIndex( src, divider ); | ||
// | if(~index) | ||
return llDeleteSubString( src, index, -1); | |||
return src; | |||
</ | }</lsl> | ||
|helpers | |||
|also_functions | |||
|also_events | |||
<lsl> | |also_tests | ||
string left (string src, string divider) { | |also_articles | ||
|location | |||
|notes | |||
|cat1=Examples | |||
} | |cat2=String | ||
</lsl> | |cat3 | ||
|cat4 | |||
}} | |||
Revision as of 09:41, 2 May 2011
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: string left( string src, string divider );
Returns text left of a specified separator
Returns a string that is the text in src that is left of the first occurrence of divider.
• string | src | |||
• string | divider |
If divider is not found then src is returned in it's entirety.
See also: Right
Specification
<lsl>string left(string src, string divider) {
integer index = llSubStringIndex( src, divider ); if(~index) return llDeleteSubString( src, index, -1); return src;
}</lsl>
Examples
<lsl>string value = left("Colour=Brown", "="); //value == "Colour"</lsl>