SETEXTRACT Extract delimited substring from a string |
Top Previous Next |
This script command extracts the specified occurrence [ num ] of a delimited substring (excluding the delimiters themselves) from [ string ] and saves the result in [ variable ]. The delimiter may be one or more characters and is specified in [ delim ].
The beginning and end of [ string ] are seen as delimiters.
Consider the following example.
;; extract "is" from string SET string = "this is a string" ;; "is" is the 2nd occurrence delimited by space (" ") SETEXTRACT substring = string " " 2 ;; substring now contains "is"
;; extract extension from file name of unknown size ;; for example, file name could be:
SETSUBSTR depth = filename "." SETNUM depth = depth + 1 SETEXTRACT extension = filename "." depth ;; extension now contains "ext"
Related Command(s): SET, SETRIGHT, SETLEFT, SETLEN, SETMID, SETSUBSTR
|