Tech Tip: Utilty method to get substring given start and end position
PRODUCT: 4D | VERSION: 15.x | PLATFORM: Mac & Win
Published On: October 19, 2016
Here is an utilty method to get a substring of a string given it's start and end position.
// Method: UTIL_SUBSTRING // Get Substring at given start position to given end position // $1 - source string // $2 - start position // $3 - end position $source:=$1 $start:=$2 $end:=$3 $len:=Length($source) If ($start<1) $start:=1 End if If ($end>$len) $end:=$len End if $0:=Substring($source;$start;($end-$start)+1) |
Example:
$string:="123456789" $sub:=UTIL_SUBSTRING($string;3;7) |