substr
substr |
Purpose
Synopsis
function substr(str:string, i1:integer, i2:integer):string
Arguments
str
|
String
|
i1
|
Starting position of the substring
|
i2
|
End position of the substring
|
Return value
Substring of the given string.
Example
write(substr("Example text", 3, 10))
This outputs the text:
ample te
Further information
This function returns the substring from the i1
th to the i2
th character of a given string (the counting starts from 1). This function returns an empty string if the bounds are not compatible with the string (
e.g. starting position larger than the length of the string) or inconsistent (
e.g. starting position after end position).