The Substr function returns a substring of another string.
result = Substr( string, n [, [ length ] [, pad ] ] ) |
Caution: n must be positive ! If the value of n is computed, you should be sure that it is greater than 0. See the last two examples below.
Examples:
say Substr( 'abracadabra', 5 ) -- shows: cadabra say Substr( 'abracadabra', 5, 3 ) -- shows: cad say Substr( 'abracadabra', 7, 7, '+' ) -- shows: dabra++ say Substr( 'abracadabra', 99, 3, '+' ) -- shows: +++
str = '' pos = min( 1, length( str ) ) say Substr( str, pos, 3, '+' ) -- B-O-M-B-S ! .. pos is 0 !
say Substr( str, max( pos, 1 ), 3, '+' ) -- OK, shows nothing |