Description
Extracts a sub-string of count
characters from the middle of another string (string
), starting at position firstIndex
. If count is -1, the remainder of string is extracted.
Functional area
String
Command syntax
Syntax
strMid "string" firstIndex count |
Arguments
Name | Type | Required | Comments |
---|---|---|---|
string | string | yes | String to extract sub-string from. |
firstIndex | integer | yes | The zero-based index of the first character in string that is to be extracted as a sub-string. |
count | integer | yes | The number of characters to extract from string, counting from firstIndex . |
Flags
None
Return value
string
Returns the sub-string from a string.
Examples
// Demonstrate usage of strMid
string $str = "This is some text";
string $subStr;
// Get 5 characters starting at index 3
$subStr = `strMid $str 3 5`;
print $subStr;
// Should be "s is "
// Get rest of string from index 8
$subStr = `strMid $str 8 -1`;
print $subStr;
// Should be "some text"