<< back to sysax.com Product page

2.6. Comparing strings

Strings can be directly compared using the string comparison operators. Additionally, strings can also be matched using wildcards such as *, and ?. This is known as wildcard matching or pattern matching. * matches 0 or more characters while ? matches exactly one character.

Exhibit 2.14. Example for how to comparing strings

if "index.txt" eq ~my_var begin

end



if "*.txt" eq ~my_var begin

end

The ftpwildcardmatch command can be used to perform wildcard matching. Additionally, this command allows case insensitive pattern matching when i is passed as a match option. If the strings match, the predefined flag ftpresult is set to the predefined constant success.

Exhibit 2.15. Syntax of command for performing wildcard matching

ftpwildcardmatch <string to match>, <wildcard pattern string>, <match options>;

Exhibit 2.16. Example for using the command for wildcard matching

ftpwildcardmatch ~my_var, "*.txt", "i"; #case insensitive wildcard match
if success eq ftpresult begin

end

The ftpregexmatch command can be used to perform matching using regular expressions similar to that used in Perl. This command allows case insensitive regular expression matching when i is passed as a match option. If the strings match, the predefined flag ftpresult is set to the predefined constant success. Note that for the regular expression pattern string, a \ character must be preceeded by another \.

Exhibit 2.17. Syntax of another string matching command

ftpregexmatch <string to match>, <regex pattern string>, <match options>;

Exhibit 2.18. Example for using the command string matching

ftpregexmatch ~my_var, "[a-zA-Z0-9]+\\.log", ""; #case sensitive regex match
if success eq ftpresult begin

end