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

Some examples are

Exhibit 2.14. table title

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.

The syntax is

Exhibit 2.15. table title

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

Some examples are

Exhibit 2.16. table title

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

The syntax is

Exhibit 2.17. table title

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

Some examples are

Exhibit 2.18. table title

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

end