How do I remove a portion of my string? [closed]
Continuing 开发者_如何学编程from my previous question, I now want to remove the number once I have found it and stored it in a variable.
Just a slight tweak to my response to your first question to instead use Regex.Replace method will git 'er done.
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);
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
精彩评论