I did a search and found a previous thread from March, 2009 which included this UDF to fix CamelCase strings:
Unfortunately, this solution doesn't seem to address several issues I'm having with my data. My data points (which happen to be colors) can include numbers and acronyms which I'd like to maintain. Here is an example of some of my data:
Logically, I need to check to see if each letter is a lowercase, uppercase or numeric result, AND if there are 2 (or more) Uppercase letters or numbers adjacent to another, they should be kept together (no space added). That seems trickier with the "USAFA Blue" and "Gray 44" examples above
It's been years since I tried my hand at regex patterns. Can anyone help me out?
Many thanks,
gpence
Code:
Function FixSpacing(r As String) As String
With CreateObject("vbscript.regexp")
.Pattern = "([a-z])([A-Z])"
.Global = True
FixSpacing = .Replace(r, "$1 $2")
End With
End Function
Unfortunately, this solution doesn't seem to address several issues I'm having with my data. My data points (which happen to be colors) can include numbers and acronyms which I'd like to maintain. Here is an example of some of my data:
CAMEL CASE | PROPER CASE |
Cobalt | Cobalt |
MidnightGreen | Midnight Green |
DeepJungleGreen | Deep Jungle Green |
AirForceAcademyBlue | Air Force Academy Blue |
USAFABlue | USAFA Blue |
CastletonGreen | Castleton Green |
SacramentoStateGreen | Sacramento State Green |
DarkGreen | Dark Green |
DeepSkyBlue4 | Deep Sky Blue 4 |
Gray44 | Gray 44 |
SeaBlue | Sea Blue |
Logically, I need to check to see if each letter is a lowercase, uppercase or numeric result, AND if there are 2 (or more) Uppercase letters or numbers adjacent to another, they should be kept together (no space added). That seems trickier with the "USAFA Blue" and "Gray 44" examples above
It's been years since I tried my hand at regex patterns. Can anyone help me out?
Many thanks,
gpence