Insert space before each capital letter - should be easy

I have a string in camel case

theDogJumped

and I need to convert it to:

the Dog Jumped

So basically insert a space before each capital letter

I think it should be easy with regular expressions, but the one thing I am not good at is how to use the match in the replacement.
LVL 35
mrichmonAsked:
Who is Participating?
 
Ravi SinghConnect With a Mentor Senior Software EngineerCommented:
Hi, try:

      string sample = "theDogJumped";
      sample = Regex.Replace(sample, "(?<cap>[A-Z])", " ${cap}");
0
 
mrichmonAuthor Commented:
Perfect Thanks!

Points increased and A awarded!
0
 
Ravi SinghSenior Software EngineerCommented:
No probs and thanks :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.