开始和匹配
BEGINS - 如果一个字符串以另一个字符串开头,则返回 TRUE。
string1 BEGINS string2
如果 string1 BEGINS 与(或等于)string2,则返回 true。否则它将返回 false。如果字符串 2 为空(“”),它将始终返回 true。
BEGINS 在你想要搜索某些内容的开头的查询中非常有用,例如名称。但它基本上是一个处理字符串的函数。
DEFINE VARIABLE str AS CHARACTER NO-UNDO.
DEFINE VARIABLE beg AS CHARACTER NO-UNDO.
str = "HELLO".
beg = "HELLO".
DISPLAY str BEGINS beg. // yes
str = "HELLO".
beg = "H".
DISPLAY str BEGINS beg. // yes
str = "HELLO".
beg = "".
DISPLAY str BEGINS beg. // yes
str = "HELLO".
beg = "HELLO WORLD".
DISPLAY str BEGINS beg. // no
**** 如果字符串中满足某些通配符,则 MATCHES 返回 true。
string1 MATCHES 表达式
如果 string1 与通配符表达式匹配,则返回 true:
*(星号)= 0 到 n 个字符(基本上任何长度的字符串)
。 (句点)=任何字符的通配符(null 除外)
DEFINE VARIABLE str AS CHARACTER NO-UNDO.
DEFINE VARIABLE beg AS CHARACTER NO-UNDO.
str = "HELLO".
beg = "HELLO".
DISPLAY str MATCHES beg. // yes
str = "HELLO".
beg = "H*".
DISPLAY str MATCHES beg. // yes
str = "HELLO".
beg = "*O".
DISPLAY str MATCHES beg. // yes
str = "HELLO WORLD".
beg = "HELLO.WORLD".
DISPLAY str MATCHES beg. // yes
str = "HELLO WORLD".
beg = "*WORL..".
DISPLAY str MATCHES beg. // no
str = "*HELLO WORLD".
beg = "WOR*LD".
DISPLAY str MATCHES beg. // no