Question: I am using WatiN to click links in the browser based on the string i pull off the site.

The problem is that some of the text it pulls is off of multiple lines, so it combines the string into 1 word. example: 
"Ultra Corrosion-Resistant Coated Alloy Steel" becomes "Ultra Corrosion-ResistantCoated Alloy Steel"

I am trying to split the string by all capital letters except ones that are hyphenated, so that i can start searching for links by portions of the string.

this is what i have so far

```
              types = doc.DocumentNode.SelectNodes("//h3[@class='AbbrPrsnttn_PrsnttnNm']");
                foreach (HtmlNode type in types)
                {
                    desc = type.InnerText.CleanText();

                    if (browser.Div(Find.ById("ProdPrsnttnGrpCntnr")).Element(Find.ByText(desc)).Exists)
                    {
                        browser.Div(Find.ById("ProdPrsnttnGrpCntnr")).Element(Find.ByText(desc)).Click();
                        System.Threading.Thread.Sleep(5000);
                        types = doc.DocumentNode.SelectNodes("//h3[@class='AbbrPrsnttn_PrsnttnNm']");
                        doc2.LoadHtml(browser.Html);
                        partTable = doc2.DocumentNode.SelectSingleNode("//div[@class='ItmTblGrp']");

                        MineNext(doc, doc2, browser, typeUrl, types, desc, partTable);
                    }

                    else
                    {
                        split = desc.Split(new Char[] { ' ' });

                    }

```

Answer: 
Here is an example of how it might be achieved:

**Updated** to also separate numbers.

```
using System;
using System.Text;

namespace SplitOnUppercase
{
    class Program
    {
        static void Main()
        {
            const string text = "Test42-10 UltraCorrosion-ResistantCoated Alloy-SteelNumberTest42";
            var result = new StringBuilder(text.Length);
            for (var i = 0; i < text.Length - 1; i++)
            {
                result.Append(text[i]);
                if (text[i] != ' ' && text[i] != '-' && (char.IsUpper(text[i + 1]) || !char.IsDigit(text[i]) && char.IsDigit(text[i + 1])))
                    result.Append(' ');
            }
            result.Append(text[text.Length - 1]);

            Console.WriteLine(result);
        }
    }
}

```
The easiest way is to make use of Regular Expression to split on capital letters (The following code won't split the string on special characters or numbers, to do so, update the regex pattern to include the special characters and numbers).

```
    var inputString = "AnyStringThatYouWantToSplitOnCap";
    var pattern = "[A-Z][a-z]+";
    Regex regex = new Regex(pattern);
    var matches = regex.Matches(inputString);
    StringBuilder value = new StringBuilder();
    foreach (Match item in matches)
    {
        value.AppendFormat("{0} ", item.Value);
    }

```