Tech Tip: Utility method to check if word ends with a given pattern
PRODUCT: 4D | VERSION: 15.2 | PLATFORM: Mac & Win
Published On: July 28, 2016
Below is an utility method to check if a word ends with a given pattern:
// Method: UTIL_ENDSWITH // Parameters: // $1 - Source string // $2 - Pattern to check for at end of source string // $0 - True if source string ends with pattern, else False C_TEXT($1;$word) C_TEXT($2;$pattern) If(Count parameters>=1) $word:=$1 $pattern:="@"+$2 $0:=($word=$pattern) End if |
Below is a example of using the method:
$word:="Hello World!" $endsWith:=UTIL_ENDSWITH($word;"rld!") //returns True $endsWith:=UTIL_ENDSWITH($word;"rld") //returns False |