Difference between revisions of "Right"
Jump to navigation
Jump to search
(New page: {{LSL Header}} __NOTOC__ <div id="box"> == Function: string right(string {{LSL Param|src}}, string {{LSL Param|divider}}); == <div style="padding: 0.5em;"> Returns text right o...) |
m (Replaced <source> with <syntaxhighlight> (and some minor things, mostly to keep code styling uniform)) |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{LSL_Function | ||
|mode=user | |||
== | |func=right | ||
|p1_type=string|p1_name=src | |||
Returns text right of a specified separator | |p2_type=string|p2_name=divider | ||
|return_type=string | |||
|return_text=that is the text in '''src''' that is right of the first occurrence of '''divider'''. | |||
|func_desc=Returns text right of a specified separator | |||
|func_footnote= | |||
If '''divider''' is not found, then '''src''' is returned in its entirety. | |||
See also: [[Left]] | See also: [[Left]] | ||
|examples= | |||
<syntaxhighlight lang="lsl2">string value = right("Colour=Brown", "="); //value == "Brown"</syntaxhighlight> | |||
|spec=<syntaxhighlight lang="lsl2">string right(string src, string divider) { | |||
string | integer index = llSubStringIndex(src, divider); | ||
// | if (~index) { | ||
return llDeleteSubString(src, 0, index + llStringLength(divider) - 1); | |||
} | |||
return src; | |||
}</syntaxhighlight> | |||
|helpers | |||
< | |also_functions | ||
|also_events | |||
string right (string src, string divider) { | |also_tests | ||
|also_articles | |||
|location | |||
|notes | |||
} | |cat1=Examples | ||
|cat2=String | |||
</ | |cat3 | ||
|cat4 | |||
}} | |||
Latest revision as of 04:05, 15 October 2023
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: string right( string src, string divider );
Returns text right of a specified separator
Returns a string that is the text in src that is right of the first occurrence of divider.
• string | src | |||
• string | divider |
If divider is not found, then src is returned in its entirety.
See also: Left
Specification
string right(string src, string divider) {
integer index = llSubStringIndex(src, divider);
if (~index) {
return llDeleteSubString(src, 0, index + llStringLength(divider) - 1);
}
return src;
}
Examples
string value = right("Colour=Brown", "="); //value == "Brown"