Core Function SubStr

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Example)
(Example)
Line 42: Line 42:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
<syntaxhighlight lang="sputnik">
 
Example using Start as a negative number
 
Example using Start as a negative number
 
say substr("UberFoX", -3); // Prints FoX
 
say substr("UberFoX", -3); // Prints FoX
 
say substr("UberFoX", -4, 2); // Prints rF
 
say substr("UberFoX", -4, 2); // Prints rF
 +
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Revision as of 17:02, 17 August 2013

SubStr( <expression>, <start>, <end> )

Contents

Description

Return part of a string

Parameters

expression

The expression to evaluate.

start

The character position to start. (0 = first character)

OR

If the start is a negative value the character position will work backwards from the length of the string.

count

Optional; The number of characters to extract. By default the entire remainder of the string.

Return Value

Success: Returns the extracted string.

Failure: Returns an empty string.

Remarks

None.

Example

$var = Substr("I am a string", 2, 2);
MsgBox("2 chars extracted from position 2 are: $var");
Example using Start as a negative number
say substr("UberFoX", -3); // Prints FoX
say substr("UberFoX", -4, 2); // Prints rF
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox