IFREGEX - Branch to label if a regular express matched in a master string

<< Click to Display Table of Contents >>

Navigation:  Robo-FTP User's Guide > Script Programming > Script Commands > All Script Commands >

IFREGEX - Branch to label if a regular express matched in a master string

Syntax:

IF[N]REGEX

 

Alt Syntax:

IF[N]REGEXI

[ string ]  [ pattern ]  GOTO  [ label ]

Arguments:

[ string ]

Variable or string defining master string.

 

[ pattern ]

Variable or string defining a regular expression pattern to match.

 

[ label ]

A valid label within the current script file which is branched to if the substring is not contained within the master string.

Options:

none

 

 

 

This script command attempts to match a regular expression with a specified master string and branches to [ label ] if it is matched or if using the IFNREGEX variant it branches if it is not matched.

 

Use the alternate IFREGEXI or IFNREGEXI command to perform the same comparison but to ignore case during the comparison. It also updates the %regex variables. %regex will be equal to the number of matched sub expressions while the %regex[0] will be set to the match found. The sub-expressions can be accessed with %regex[n] where n is the sub-expression.

 

Consider the following simple example with one sub-expression that results in a branch to the specified label.

 

SET master_string = "abcdefg"

SET pattern = "a(.)c"

IFREGEX master_string pattern GOTO pattern_matched

 

After the branch to the pattern_matched label the following variables will be set in this case:

Variable

Value

%regex

1

%regex[0]

abc

%regex[1]

b

 

Related command(s): IFSTRCMP, IFNSTRCMP, IFSUBSTR, UPPER, LOWER