;~~Author~~. Steve Iatropoulos ;~~Email_Address~~. siatro@ipex.de ;~~Script_Type~~. Kix ;~~Sub_Type~~. Misc ;~~Keywords~~. delimiters, substrings ;~~Comment~~. ;Subsroutine to extract substrings based on delimiters passed in. Probably could be oprimised further but I found it useful nonetheless. ;~~Script~~. ; Search for a substring within a string bound between two delimiters. Eg retunrn 1234 in string w1111-1234-n ; (bound between - and -). ; ; v1.0 ; ; ; Passed in parameters: ; Set the following variables before invoking ; $string=string to search in ; $from = where to start extracting from, ^ means start of string ; $to = where you want to stop extracting (or end of string, whichever comes first) ; $repeat=At which nth occurence to start the search from (useful if you have multiple delimiters and you dont want to start ; from the first occurence of $from) ; ; Returns the extracted substring in $retstr ; $i = 1 $retstr = "" $c = "" $length = 0 $length = LEN($string) ; ; Scan string until the right occurence of '$from' is reached. ; WHILE $i <= $length AND $repeat > 0 AND $from <> "^" $c = substr($string, $i, 1) $i = $i + 1 IF $c = $from $repeat=$repeat - 1 ENDIF LOOP $c = substr($string, $i, 1) WHILE $i <= $length AND $c <> $to $i = $i + 1 $retstr = $retstr + $c $c = substr($string, $i, 1) LOOP