我有一个代码部分,它检查字符串是否都是小写的。如果是的话,它给我的第一个和最后一个字符作为缩写。如果不是,它给我大写部分作为缩写。
if Hotstring is lower
{
ShortString := SubStr(Hotstring,1,1) . SubStr(Hotstring,0)
}else{
ShortString := RegExReplace(Hotstring, "[a-záéiíóöőúüű ]", "")
StringLower,ShortString, ShortString
} 问题:如果输入字符串包含中欧字符,则该字符串不能正确识别为小写。
发布于 2018-05-30 12:18:28
对下列各项进行了测试才能发挥作用:
If RegExMatch(Hotstring, "(*UCP)^[[:lower:] ]+$")
; or just "(*UCP)^[[:lower:]]+$" if you want to stick with the exact definition of the "lower" type
ShortString := SubStr(Hotstring, 1, 1) SubStr(Hotstring, 0)
Else
ShortString := Format("{:L}", RegExReplace(Hotstring, "(*UCP)[[:lower:] ]+"))一种功能相同、但更简洁的备选方案:
ShortString := Hotstring ~= "(*UCP)^[\p{Ll} ]+$"
? SubStr(Hotstring, 1, 1) SubStr(Hotstring, 0)
: Format("{:L}", RegExReplace(Hotstring, "(*UCP)[\p{Ll} ]+"))https://stackoverflow.com/questions/50599044
复制相似问题