substring: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Added version.)
m (Incorrectly specified that negative indices meant counting from the end)
 
(5 intermediate revisions by 4 users not shown)
Line 3: Line 3:
|version=1.3b48
|version=1.3b48
|description=
|description=
Returns the substring of the string from the start to the end indexes. Indexes for strings start at 0. If the end parameter is not specified then the substring extends to the end of the string.
Returns the substring of the string from the start to the end indexes. Indexes for strings start at 0. If the end parameter is not specified, then the substring extends to the end of the string.


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
substring(str, start)
substring(str, start)
</source>
</syntaxhighlight>
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
substring(str, start, end)
substring(str, start, end)
</source>
</syntaxhighlight>


|examples=
|examples=
<source lang="mtmacro" line>
<syntaxhighlight  lang="mtmacro" line>
     [substring("This is a test", 5)]
     [substring("This is a test", 5)]
     [substring("This is a test", 5, 7)]
     [substring("This is a test", 5, 7)]
</source>
</syntaxhighlight>
Returns  
Returns  
<pre>
     is a test
     is a test
     is
     is
</pre>
}}
}}
[[Category:String Function]]
[[Category:String Function]]

Latest revision as of 02:18, 8 June 2024

substring() Function

Introduced in version 1.3b48
Returns the substring of the string from the start to the end indexes. Indexes for strings start at 0. If the end parameter is not specified, then the substring extends to the end of the string.

Usage

substring(str, start)
substring(str, start, end)

Examples

    [substring("This is a test", 5)]
    [substring("This is a test", 5, 7)]

Returns

    is a test
    is