Solved

Insert space before each capital letter - should be easy

Posted on 2006-11-28
3
1,006 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Server Error 11 58
how to read json value 2 49
Eagerly loading related objects in entity framework 5 30
C# 2015 Downloading text file and preserving the line breaks 5 37
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…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 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