SETSUBSTR        Find number of substrings in string

Top  Previous  Next

Syntax:

SETSUBSTR

[ variable ]  =  [ string ] [ substr ]

Arguments:

[ variable ]

Variable to assign; if the variable does not previously exist it is created.

 

[ string ]

Variable or string defining the value of string from which to obtain the delimiter count.

 

[ substr ]

Variable or string defining the delimiter string to search for within [ string ]. A delimiter can be one or more characters in length.

Options:

None

 

 

 

This script command searches [ string ] for occurences of [ substr ] and saves the number of occurences found in [ variable ].

 

Consider the following examples.

 

;; find the number of file name segments

SET filename = "data.temporary.sbc.xml"

;; find how many "." occur

SETSUBSTR dots = filename "."

;; dots will be equal to 3 (segments equals dots + 1)

 

;; determine if file name has an extension

SETSUBSTR dots = filename "."

IFNUM= dots 0 goto no_extension

 

Related Command(s):        SET, SETEXTRACT, SETRIGHT, SETLEFT, SETLEN, SETMID