I have a string: CategoryName
I need to add space between Category and Name.
So I have to insert a space before each capital letter.
var input = "CategoryName";
var result = Regex.Replace(input, "([a-z])([A-Z])", @"$1 $2"); //Category Name
UPDATE (this will treat sequence of capital letters as one word)
var input = "SimpleHTTPRequest";
var result = Regex.Replace(input, "([a-z]|[A-Z]{2,})([A-Z])", @"$1 $2");
//Simple HTTP Request
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With