Difference between revisions of "Right"

From Second Life Wiki
Jump to: navigation, 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 (<lsl> tag to <source>)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{LSL Header}} __NOTOC__
+
{{LSL_Function
<div id="box">
+
|mode=user
== Function: [[string]] right([[string]] {{LSL Param|src}}, [[string]] {{LSL Param|divider}}); ==
+
|func=right
<div style="padding: 0.5em;">
+
|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 it's entirety.
  
 
See also: [[Left]]
 
See also: [[Left]]
 
+
|examples=
Example:<br />
+
<source lang="lsl2">string value = right("Colour=Brown", "="); //value == "Brown"</source>
 
+
|spec=<source lang="lsl2">string right(string src, string divider) {
string notecardparameter = right(sdata,"=");
+
    integer index = llSubStringIndex( src, divider );
//in a notecard line that reads Colour=Brown, returns "Brown"
+
    if(~index)
 
+
        return llDeleteSubString( src, 0, index + llStringLength(divider) - 1);
 
+
    return src;
</div></div>
+
}</source>
<div id="box">
+
|helpers
== Specification ==
+
|also_functions
<div style="padding: 0.5em;">
+
|also_events
<lsl>
+
|also_tests
string right (string src, string divider) {
+
|also_articles
      integer iStart = llSubStringIndex( src, divider ) + 1;
+
|location
      string result = llGetSubString( src, iStart, llStringLength(src) - 1 ) ;
+
|notes
      return result;
+
|cat1=Examples
}
+
|cat2=String
 
+
|cat3
</lsl>
+
|cat4
</div></div>
+
}}
 
+
{{LSLC|Examples|right}}
+

Latest 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"