I\'m using the regex
System.Text.RegularExpressions.Regex.Replace(stringToSplit, \"([A-Z])\", \" $1\").Trim()
to split strings by capital l
Tomalak's expression worked for me, but not with the built-in Replace
function. Regex.Replace()
, however, did work.
For i As Integer = 0 To names.Length - 1
'Worked
names(i) = Regex.Replace(names(i), "((?<=[a-z])[A-Z]|[A-Z](?=[a-z]))", " $1").TrimStart()
' Didn't work
'names(i) = Replace(names(i), "([A-Z])(?=[a-z])|(?<=[a-z])([A-Z])", " $1").TrimStart()
Next
BTW, I'm using this to split the words in enumeration names for display in the UI and it works beautifully.