如何使用like函数检查字符表达式是否在文本开头包含“*”
How to check whether a character expression contains a "*" in the beginning of the text using the like function
cFilterprodname=upper(thisform.textbox1.text)
IF LIKE('*'+"%",cFilterprodname)=.T.
MESSAGEBOX("* found in the beginning")
ELSE
MESSAGEBOX("* not found in the beginning")
ENDIF
这是我试过的代码,它会跳转到 else 块,即使它的开头有“*”。有人可以帮助我吗?
LIKE
函数不是这样工作的。首先,'*' 是一个通配符,匹配任意数量的字符,所以它不会匹配字符。
其次,来自帮助文件:
cExpression2 must match cExpression1 letter for letter in order for LIKE( ) to return true (.T.).
如果你想检查第一个字符是否是'*',这会起作用并且应该更容易理解。
IF LEFT(cFilterprodname, 1) == "*"
MESSAGEBOX("* found in the beginning")
ELSE
MESSAGEBOX("* not found in the beginning")
ENDIF
cFilterprodname=upper(thisform.textbox1.text)
IF LIKE('*'+"%",cFilterprodname)=.T.
MESSAGEBOX("* found in the beginning")
ELSE
MESSAGEBOX("* not found in the beginning")
ENDIF
这是我试过的代码,它会跳转到 else 块,即使它的开头有“*”。有人可以帮助我吗?
LIKE
函数不是这样工作的。首先,'*' 是一个通配符,匹配任意数量的字符,所以它不会匹配字符。
其次,来自帮助文件:
cExpression2 must match cExpression1 letter for letter in order for LIKE( ) to return true (.T.).
如果你想检查第一个字符是否是'*',这会起作用并且应该更容易理解。
IF LEFT(cFilterprodname, 1) == "*"
MESSAGEBOX("* found in the beginning")
ELSE
MESSAGEBOX("* not found in the beginning")
ENDIF