• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1055
  • Last Modified:

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.
0
mrichmon
Asked:
mrichmon
  • 2
1 Solution
 
Ravi SinghSenior 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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now