Along the lines of a similar question to split CamelCase items into Title Case in Java, I want to do the same with VBScript. Essentially, I want to end up with a helper function that works like this:
SplitCamelCase ( "lowercase" ) ' Returns: "lowercase"
SplitCamelCase ( "Class" ) ' Returns: "Class"
SplitCamelCase ( "MyClass" ) ' Returns: "My Class"
SplitCamelCase ( "HTML" ) ' Returns: "HTML"
SplitCamelCase ( "PDFLoader" ) ' Returns: "PDF Loader"
SplitCamelCase ( "AString" ) ' Returns: "A String"
SplitCamelCase ( "SimpleXMLParser" ) ' Returns: "Simple XML Parser"
SplitCamelCase ( "GL11Version" ) ' Returns: "GL 11 Version"
And before anyone asks... This is not for a homework assignment. :) Among other possible uses, I want to split WMI Property Names into a human-readable format.
Here's a meager attempt, cobble together from an example Excel Macro:
Function SplitCamel( txt )
Dim Hold , i
Hold = Left(txt, 1)
For i = 2 To Len(txt) Step 1
If Asc(Mid(txt, i, 1)) > 96 Then
Hold = Hold & Mid(txt, i, 1)
Else
Hold = Hold & " " & Mid(txt, i, 1)
End If
Next
SplitCamel = Hold
End Function
WScript.Echo SplitCamel( "CSDVersion" ) ' Returns: "C S D Version"
... which does some splitting, but obviously is not what the end goal is.