How do you split a string like "TheFoxRanOverTheHill" into "The Fox Ran Over The Hill" using regular expression
I've searched all over and I am not sure how you can split "TheFoxRanOverTheHill" into "The Fox Ran Over The Hill" using regular expression when there is no delimiter other than the captial letter tells you it is a start of another word. Thanks for all the replies.
asianguyinaustinPosted May 6, 2009, 9:09 AM
Kirtan PatelPosted May 5, 2009, 5:31 PM
private void button1_Click(object sender, EventArgs e)
{
string str = textBox1.Text.Trim();
Regex re = new Regex("[A-Z]*[a-z]*");
MatchCollection mc = re.Matches(str);
StringBuilder sb = new StringBuilder();
foreach (Match m in mc)
{
sb = sb.Append(" " + m.ToString());
}
MessageBox.Show("Final String is =" +sb.ToString() );
}
Happy Coding :)
asianguyinaustinPosted May 5, 2009, 9:43 AM
I want to count words in any phrase. There is no delimiter so I don't know how to indicate there are many words in a string like "TheFoxRanOverTheHill" there are 6 words in this string. The string contains no spaces.
Bechir BejaouiPosted May 4, 2009, 5:56 PM
The Fox Ran Over The Hill
or you want to apply this to any kind of phrase?