KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: String comparison using wildcards
PRODUCT: 4D | VERSION: 11 | PLATFORM: Mac & Win
Published On: April 30, 2009

When using the wildcard character "@" to compare strings, the position (left or right) of the string containing the "@" symbol can affect the outcome of the test. This means that switching the order of the strings can lead to different results.

Take the following example:

C_BOOLEAN($test1;$test2)

$test1:="abc@"= "abc" `evaluates to false
$test2:="abc"="abc@" `evaluates to true

If ($test1=$test2)
    ALERT("The tests are the same.")
Else
    ALERT("The tests are different.")
End if



In the code above, $test1 and $test2 are not equivalent and the resulting alert message displays the text "The tests are different". This is because when the wildcard character is used in the string to the right of the '=', it matches any number of characters, but when used to the left of the '=', the wildcard character only matches one character.