-
Notifications
You must be signed in to change notification settings - Fork 1
Substring Operator
Martin Danielsson edited this page Jul 23, 2015
·
2 revisions
The Substring
operator. Takes one string and two integer parameters.
What | Type |
---|---|
Syntax | Substring(s, offset, length) |
s |
string |
offset |
int |
length |
int |
Return type | string |
The Substring
operator follows these rules:
- If the offset is larger than the string length, the operator returns
""
- If the length is larger than the string length minus the offset, the operator returns the entire string from the offset on (but does not pad!)
- If the length is negative, the entire string from offset on is returned.
Examples:
Expression | Result |
---|---|
Substring("Hello, World!", 0, 5) |
"Hello" |
Substring("Hello, World!", 7, 100) |
"World!" |
Substring("Hello, World!", 20, 10) |
"" |
Substring("Hello, World!", 7, -1) |
"World!" |