Solved

Insert space before each capital letter - should be easy

Posted on 2006-11-28
3
1,016 Views
Last Modified: 2008-01-09
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
Comment
Question by:mrichmon
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 250 total points
ID: 18030722
Hi, try:

      string sample = "theDogJumped";
      sample = Regex.Replace(sample, "(?<cap>[A-Z])", " ${cap}");
0
 
LVL 35

Author Comment

by:mrichmon
ID: 18031571
Perfect Thanks!

Points increased and A awarded!
0
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 18040650
No probs and thanks :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question