StrLower / StrUpper / StrTitle

将字符串转换为小写, 大写, 或标题大小写.

NewString := StrLower(String)
NewString := StrUpper(String)
NewString := StrTitle(String)

参数

String

类型: 字符串

要转换的字符串.

返回值

类型: 字符串

这些函数返回指定字符串转换后的新版本.

备注

要判断一个字符或字符串是完全大写还是小写, 请使用 IsUpper, IsLowerRegExMatch 函数. 例如:

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)  ; 即输出可以和输入相同.

转换字符串为大写, 并将 "THIS IS A TEST." 存储在 String2.

String2 := "This is a test."
String2 := StrUpper(String2)

转换字符串为标题大写并将 "This Is A Test." 存储在 String3.

String3 := "This is a test."
String3 := StrTitle(String3, "T")