KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Wildcard @ in middle of string depends on database text comparison setting
PRODUCT: 4D | VERSION: 17 | PLATFORM: Mac & Win
Published On: December 28, 2018

When comparing a string against another string with the @ wildcard in the middle, there can be different outcomes depending on a particular setting.



When navigating from the top toolbar to Design > Database Settings > Database, the setting "Consider @ as a wildcard only when at the beginning or end of text patterns" when enabled can cause errors if the wild card is used in the middle of a string.

Take the example below where a string is tested against another string with the wildcard in the middle.

C_BOOLEAN($isValidString_b)
C_TEXT($test1_t;$test2_t)

$test1_t:="abcdefg"
$test2_t:="a@g"
$isValidString_b:=($test1_t=$test2_t)


If the setting "Consider @ as a wildcard only when at the beginning or end of text patterns" is checked and the code is executed, the @ wildcard in the middle of the string will be completely ignored and the comparison will return false.



However, unchecking the setting mentioned above will allow wildcards in the middle of the string, and the string comparison will be valid.



In conclusion, always be sure that the setting above is unchecked when deciding to use @ wildcards in the middle of a string.