Returns a substring of the specified string.
If the length is greater than zero, the function returns a substring starting at character position startIndex with a length of length characters.
If the length is equal to zero, the function returns an empty string.
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | startIndex or length is less than zero. |
ArgumentOutOfRangeException | startIndex is greater than the length of str. |
ArgumentOutOfRangeException | startIndex plus length indicates a position not within str. |
string::substring('testing string', 0, 4) ==> 'test'
string::substring('testing string', 8, 3) ==> 'str'
string::substring('testing string', 8, 0) ==> ''
string::substring('testing string', -1, 5) ==> ERROR
string::substring('testing string', 8, -1) ==> ERROR
string::substring('testing string', 5, 17) ==> ERROR
StringFunctions Class | NAnt.Core.Functions Namespace