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 ].

 

The following example uses SETSUBSTR to determine if a filename has no extension:

 

SET filename = "MyData"

SETSUBSTR dots = filename "."

IFNUM= dots 0 GOTO no_extension

 

The following example finds the number of file name segments:

 

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

;; find how many "." occur

SETSUBSTR dots = filename "."

;; the number of segments is one more than the number of dots

SETNUM segments = dots + 1

 

The SETSUBSTR can be used to detect and remove unwanted characters from the names of files to be downloaded. The SETEXTRACT and SETRIGHT commands are also useful for parsing a filenames.

 

 

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