开发者

How do I remove a portion of my string? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜