将字符串转换为小写, 大写, 或标题大小写.
NewString := StrLower(String) NewString := StrUpper(String) NewString := StrTitle(String)
类型: 字符串
要转换的字符串.
类型: 字符串
这些函数返回指定字符串转换后的新版本.
要判断一个字符或字符串是完全大写还是小写, 请使用 IsUpper, IsLower 或 RegExMatch 函数. 例如:
var := "abc" if isUpper(var) MsgBox "var is empty or contains only uppercase characters." if isLower(var) MsgBox "var is empty or contains only lowercase characters." if RegExMatch(var, "^[a-z]+$") MsgBox "var is not empty and contains only lowercase ASCII characters." if !RegExMatch(var, "[A-Z]") MsgBox "var does not contain any uppercase ASCII characters."
Format 也能实现大小写变换, 如下所示:
MsgBox Format("{:U}, {:L} and {:T}", "upper", "LOWER", "title")
InStr, SubStr, StrLen, StrReplace
转换字符串为小写, 并将 "this is a test." 存储在 String1.
String1 := "This is a test." String1 := StrLower(String1) ; 即输出可以和输入相同.