Question : VB.NET: strings - how to insert space between words (capital letters)

Hi X-perts,

I need to convert strings like "BusinessServiceShort" into "Business Service Short"

strings may contain different number of words.

What is the easiest and elegant way of doing this?

Thanks

Answer : VB.NET: strings - how to insert space between words (capital letters)

Hi Andy,
You can use this regex:
[A-Z][^A-Z].*?(?=[A-Z\d]|$)|[A-Z]+(?=[A-Z\d][a-z]|$)|\d+(?=[\w-\d])

so:
str = Trim(RegularExpressions.Regex.Replace("BusinessSerXXXviceShort", "[A-Z][^A-Z].*?(?=[A-Z\d]|$)|[A-Z]+(?=[A-Z\d][a-z]|$)|\d+(?=[\w-\d])", " ${0}"))

Enjoy!
P.
Random Solutions  
 
programming4us programming4us