Tech Tip: Utility Methods for Quick "is One Of" Checks
PRODUCT: 4D | VERSION: 21 | PLATFORM: Mac & Win
Published On: February 10, 2026
These utility methods encapsulates the % operator and collection for checking if a value is one of the whole words in a space-separated list (or any delimited string).
IsInWordList_Percent:Lightweight version using % , whole-word only and space-delimited
Checks if $value is a complete whole word in $list (space-separated)
Limitations:
IsInWordList_Collection: more robust version using Collection with a flexible delimiter
Use this one when having custom delimiters (",", ";", etc.) and exact string match not just word-boundary
Test examples:
IsInWordList_Percent:Lightweight version using % , whole-word only and space-delimited
Checks if $value is a complete whole word in $list (space-separated)
- very useful for space-separated lists (tags, statuses, roles…)
- zero allocations, therefore best performance in tight loops
| #DECLARE($list : Text; $value : Text) : Boolean If (Trim($value)="") return False End if $list:=Trim($list) return ($list%$value) |
Limitations:
- Only spaces as delimiter
- No custom trimming per word
- Multi-word $value always: False
IsInWordList_Collection: more robust version using Collection with a flexible delimiter
Use this one when having custom delimiters (",", ";", etc.) and exact string match not just word-boundary
| #DECLARE($list : Text; $value : Text; $delimiter : Text; $caseSensitive : Boolean)\ ->$isFound : Boolean If (Count parameters<3) $delimiter:=" " End if If (Count parameters<4) $caseSensitive:=False End if If (Not($caseSensitive)) $value:=Lowercase($value) $list:=Lowercase($list) End if var $words : Collection $words:=Split string($list; $delimiter; sk trim spaces+sk ignore empty strings) $isFound:=$words.includes($value) |
Test examples:
| var $colors : Text $colors:="red green blue yellow" var $test : Text $test:="green" If (IsInWordList_Percent($colors; $test)) ALERT("found") End if If (IsInWordList_Collection($colors; $test; " ")) ALERT("found") End if var $fruits : Text $fruits:="apple, banana, raspberry" // Comma example If (IsInWordList_Collection($fruits; "banana"; ",")) ALERT("Banana found!") End if |