views:

53

answers:

3

Continuing from my previous question, I now want to remove the number once I have found it and stored it in a variable.

A: 

Don't worry I figured it out. Just need to find the length then delete the chars (qual is the intergers found)

string length = qual.ToString();
            int length2 = length.Length;
            text.Remove(0, length2);
Liam E-p
You probably meant: `text = text.Remove(0, length2);` since the string operations return a new string and do not affect the current instance (strings are immutable). Another option is `text = text.Substring(length2);`
Ahmad Mageed
A: 

I think the following code resolves the root problem:

string originalString = "35|http://www.google.com|123";
string[] elements = originalString.Split(new char[] { '|' }, 2);
int theNumber = int.Parse(elements[0]);   // 35
string theUrl = elements[1];              // http://www.google.com|123
Danny Chen
+2  A: 

Just a slight tweak to my response to your first question to instead use Regex.Replace method will git 'er done.

burkestar