Difference between revisions of "Right"

From Second Life Wiki
Jump to navigation Jump to search
m (added to Category:LSL String)
m (<lsl> tag to <source>)
(One intermediate revision by one other user not shown)
Line 12: Line 12:
See also: [[Left]]
See also: [[Left]]
|examples=
|examples=
<lsl>string value = right("Colour=Brown", "="); //value == "Brown"</lsl>
<source lang="lsl2">string value = right("Colour=Brown", "="); //value == "Brown"</source>
|spec=<lsl>string right(string src, string divider) {
|spec=<source 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;
}</lsl>
}</source>
|helpers
|helpers
|also_functions
|also_functions
Line 27: Line 27:
|notes
|notes
|cat1=Examples
|cat1=Examples
|cat2
|cat2=String
|cat3
|cat3
|cat4
|cat4
}}
}}
[[Category:LSL String]]

Revision as of 17:45, 24 January 2015

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 it's 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"