我正在使用VBScript RegEx
Dim RegEx : RegEx = new RegExp
Dim stringValue : stringValue = "StudentID"
Dim NiceName
With RegEx
.Pattern = "([A-Z])(?![A-Z])"
.IgnoreCase = False
.Global = True
End With
NiceName= RegEx.Replace(stringValue , " $1")
NiceName应为“学生证”
我得到“StudentI D”
注意:此模式适用于没有两个大写字符的字符串。
我尝试了以下模式,但它们在VBSCript中生成错误:
"(?<!^)([A-Z][a-z]|(?<=[a-z])[A-Z])"
"(?<=[A-Z])(?=[A-Z][a-z])|(?<=[^A-Z])(?=[A-Z])|(?<=[A-Za-z])(?=[^A-Za-z])"
答案 0 :(得分:0)
不知道真正的必需品,也许这可行。只需替换一个小写字母后跟一个大写字母,两个字母用空格分隔
Option Explicit
Dim stringValue
stringValue="the StudentID has a RareCaseOfUpperCASE"
With New RegExp
.Pattern = "([a-z])([A-Z])"
.IgnoreCase = False
.Global = True
WScript.Echo .Replace(stringValue, "$1 $2")
End With
输出:the Student ID has a Rare Case Of Upper CASE