Parsing the integer part of string
<p>I have a string which could be entered as <code>{n}d {n}h {n}m {n}s</code> where <code>{n}</code> is a integer denoting the number of days, hours, min, sec. How would I extract this <code>{n}</code> number from the string?</p>

<p>The user does not have to enter all 4 - d, h, m, s. He could only enter 4d which means 4 days or 5h 2s which means 5 hours and 2 sec. </p>

<p>Here's what I have. Definitely there should be a better way to do this. Also, does not cover all cases. </p>

<pre><code>int d; int m; int h; int sec;
string [] split = textBox3.Text.Split(new Char [] {' ', ','});
List&lt;string&gt; myCollection = new List&lt;string&gt;();

foreach (string s in split)
{
    d = Convert.ToInt32(s.Substring(0,s.Length-1));
    h = Convert.ToInt32(split[1].Substring(1));
    m = Convert.ToInt32(split[2].Substring(1));
    sec = Convert.ToInt32(split[3].Substring(1));
}
dt  =new TimeSpan(h,m,s);
</code></pre>
