Difference between revisions of "Right"

From Second Life Wiki
Jump to navigation Jump to search
m (<lsl> tag to <source>)
m (Replaced <source> with <syntaxhighlight> (and some minor things, mostly to keep code styling uniform))
 
Line 8: Line 8:
|func_desc=Returns text right of a specified separator
|func_desc=Returns text right of a specified separator
|func_footnote=
|func_footnote=
If '''divider''' is not found then '''src''' is returned in it's entirety.
If '''divider''' is not found, then '''src''' is returned in its entirety.


See also: [[Left]]
See also: [[Left]]
|examples=
|examples=
<source lang="lsl2">string value = right("Colour=Brown", "="); //value == "Brown"</source>
<syntaxhighlight lang="lsl2">string value = right("Colour=Brown", "="); //value == "Brown"</syntaxhighlight>
|spec=<source lang="lsl2">string right(string src, string divider) {
|spec=<syntaxhighlight lang="lsl2">string right(string src, string divider) {
     integer index = llSubStringIndex( src, divider );
     integer index = llSubStringIndex(src, divider);
     if(~index)
     if (~index) {
         return llDeleteSubString( src, 0, index + llStringLength(divider) - 1);
         return llDeleteSubString(src, 0, index + llStringLength(divider) - 1);
    }
     return src;
     return src;
}</source>
}</syntaxhighlight>
|helpers
|helpers
|also_functions
|also_functions

Latest revision as of 03:05, 15 October 2023

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"