propercase.vbs

来自「Apress - Managing Enterprise Systems Wit」· VBS 代码 · 共 19 行

VBS
19
字号
Dim objRegExp

Set objRegExp = New RegExp
objRegExp.IgnoreCase = True
objRegExp.Pattern = "\w+\b"
objRegExp.Global = True

Wscript.Echo _ 
   objRegExp.Replace("FRED MCTAVISH", GetRef("Proper"))

Function Proper(strMatch, nPos, strSource)
 'check if the match starts with MC
 If StrComp(Left(strMatch,2), "Mc", vbTextCompare)=0 Then
  Proper= "Mc" & Ucase(Mid(strMatch,3,1)) & Lcase(mid(strMatch,4))
 Else
  Proper= Ucase(Left(strMatch,1)) & Lcase(mid(strMatch,2))
 End If
End Function

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?