Topic group Related topics Example
Returns a substring derived from a specified character string.
SUBSTR(<expC>, <start expN> [, <length expN>])
The string you want to extract characters from.
The character position in the string to start extracting characters.
The number of characters to extract from the string.
Starting in a character expression at the position you specify for <start expN>, SUBSTR( ) returns the number of characters you specify for <length expN>. If <start expN> is greater than the length of <expC>, or <length expN> is zero or a negative number, SUBSTR( ) returns an empty string.
If you don't specify <length expN>, SUBSTR( ) returns all characters starting from position <start expN> to the end of the string. If <length expN> is greater than the number of characters from <start expN> to the end of the string, SUBSTR( ) returns only as many characters as are left in the string, without adding space characters to achieve the specified length. You can use LEN( ) to determine the actual length of the returned string.
When SUBSTR( ) returns characters from a memo field, it counts two characters for each carriage-return and linefeed combination (CR/LF) in the memo field.
The substring( ) method is similar to the SUBSTR( ) function, but in addition to the syntactic difference of being a method instead of a function and the fact that the position is zero-based, the method takes a starting and ending position, while the function takes a start position and the number of character to extract.