STR_MATCH

Use the STR_MATCH script function to compare whether the two strings String2 and String1 are identical. The comparison is case sensitive, so upper and lower case are distinguished.

Syntax

STR_MATCH (String1, String2[, Wildcard1[, Wildcard2]])

  • STR_MATCH
    Compares two strings

  • String1
    Alphanumeric character string that should be compared
    Format: script literal or script variable

  • String2
    Alphanumeric character string that should be compared. You can use wildcard characters to form a comparison pattern where "*" stands for any character and "_" for exactly one.
    Format: script literal or script variable

  • Wildcard1
    (Optional) Character that represents any character. You can use and assign any wildcard characters.
    Format: script literal or script variable
    Default: "*"

  • Wildcard2
    (Optional) Character that represents any character. You can use and assign any wildcard characters.
    Format: script literal or script variable
    Default: "*"

Return codes

  • Y
    The two strings are identical
  • N
    The two strings are not identical

Note: If a variable contains a blank, the check for a variable length that is zero returns the value "N" as the following example shows:

:SET&TEST# = GET_VAR(‚VARA.TEST‘,‘KEY_DOES_NOT_EXIST‘)
:SET&TRUE#=STR_MATCH(&TEST#,"")

Examples

The sample strings below are not the same, so this script returns a negative code (N).

:SET &COMPARISON# = STR_MATCH("AE", "global")

The following example uses a wildcard character for comparison. The strings match, so the positive result (Y) is printed in the activation report.

:SET &RET# = STR_MATCH("PromptSet", "P*S*")
:
PRINT &RET#

The following example uses a wildcard character that is explicitly specified. The strings match, so the positive result (Y) is printed in the activation report.

:SET &RET# = STR_MATCH("PromptSet", "Prompt#", "#")
:
PRINT &RET#

The following example includes a wildcard character that stands for exactly one character. In this case, the strings do not match, so the negative result (N) is printed in the activation report.

:SET &RET# = STR_MATCH("PromptSet", "Prompt#",, "#")
:
PRINT &RET#

See also: