I mean I am a beginner for this one, and any tutorial would be prefered, I have Googled enough, and I am not able to understand what it is. If any of you can tell me what to do? I can get the idea.
Basic is that url would be like
localhost:xxxx/afzaal.ahmad.zeeshan
now I need to split it from "." and to get only the figures, no other chars. Secondly I need to split it at any other character that user could add to text. Any help?
Read more of my web development posts on my website. Thank you.
string strTest = "localhost:xxxx/afzaal.ahmad.zeeshan";
string[] splitResult = strTest.Split('.');
for (int i = 0; i < splitResult.Length; i++)
{
Response.Write(splitResult[i].ToString());
Response.Write("</br>");
}
Thanks for reply, but I don't want to write it with line break, I simple want the code to split the string. To get the output without those characters (".", ",") and others.
Read more of my web development posts on my website. Thank you.
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "";
string mystr = "localhost:xxxx/afzaal.ahmad.zeeshan";
string[] mysplit = mystr.Split('.');
for (int i = 0; i < mysplit.Count(); i++)
{
Label1.Text += string.Format("mysplit[{0}]={1}</br>", i, mysplit[i]);
}
}
Good idea for button, but as earlier mentioned, I am having the code in an Ajax page. So no button would be clicked!
Secondly I have tried the same, you can see it in my previous post. I am having URL as variable, then I get the URL as a string. Then I split it, but I get error as:
CS1502: The best overloaded method match for 'string.Split(params char[])' has some invalid arguments
Any help?
Read more of my web development posts on my website. Thank you.
Contributor
4010 Points
1926 Posts
String.Split
May 02, 2013 01:53 PM|Afzaal.Ahmad.Zeeshan|LINK
I need to learn how to split a string?
I mean I am a beginner for this one, and any tutorial would be prefered, I have Googled enough, and I am not able to understand what it is. If any of you can tell me what to do? I can get the idea.
Basic is that url would be like
now I need to split it from "." and to get only the figures, no other chars. Secondly I need to split it at any other character that user could add to text. Any help?
Contributor
4954 Points
1726 Posts
Re: String.Split
May 02, 2013 03:54 PM|thirumaran007|LINK
With Friendly,
Thirumaran
Star
13450 Points
2764 Posts
Re: String.Split
May 02, 2013 04:02 PM|Nasser Malik|LINK
Salam Afzal,
Frist kindly give us an example what you want from you string with example. (string and expected output)
and to learn split method kinldy see following tutorials
Regards.
Skype: maleknasser1
LinkedIn: https://www.linkedin.com/in/maliknasser
All-Star
52523 Points
15672 Posts
Re: String.Split
May 02, 2013 09:28 PM|oned_gk|LINK
Add button and label to your page
then use click event
Suwandi - Non Graduate Programmer
Contributor
4010 Points
1926 Posts
Re: String.Split
May 03, 2013 04:42 AM|Afzaal.Ahmad.Zeeshan|LINK
Thanks for reply, but I don't want to write it with line break, I simple want the code to split the string. To get the output without those characters (".", ",") and others.
Contributor
4010 Points
1926 Posts
Re: String.Split
May 03, 2013 04:47 AM|Afzaal.Ahmad.Zeeshan|LINK
Wa salam Malik sahib,
I want to get this URL
as
The links you have provided, I have checked both, the dotnetperls has a C# method, So I have tried it, but still I get the error.
Second link, I have not yet explored it fully, but have checked. Will give it a second try!
My URL is as provided and the code something I am trying is like
Where URL =
So any (I know there would be many errors) error in the code?
Actually I am having this code in an ajax request, The code is working correct, But I need to split the string user sends, and get ony alphabets!
Contributor
4010 Points
1926 Posts
Re: String.Split
May 03, 2013 04:50 AM|Afzaal.Ahmad.Zeeshan|LINK
Good idea for button, but as earlier mentioned, I am having the code in an Ajax page. So no button would be clicked!
Secondly I have tried the same, you can see it in my previous post. I am having URL as variable, then I get the URL as a string. Then I split it, but I get error as:
CS1502: The best overloaded method match for 'string.Split(params char[])' has some invalid arguments
Any help?
Member
50 Points
21 Posts
Re: String.Split
May 03, 2013 04:59 AM|sachinp290|LINK
string[] result = splitname.Split('.');
Contributor
2006 Points
725 Posts
Re: String.Split
May 03, 2013 05:14 AM|sanjayverma_mca|LINK
Hi ,
try this
Hope this will help you
Contributor
4010 Points
1926 Posts
Re: String.Split
May 03, 2013 07:13 AM|Afzaal.Ahmad.Zeeshan|LINK
Actually as mentioned, the URL has only "afzaal.ahmad.zeeshan" value!
All-Star
52523 Points
15672 Posts
Re: String.Split
May 03, 2013 07:49 AM|oned_gk|LINK
Suwandi - Non Graduate Programmer
Contributor
4010 Points
1926 Posts
Re: String.Split
May 03, 2013 08:38 AM|Afzaal.Ahmad.Zeeshan|LINK
I have already posted.
1. My url would be like
I will extract the afzaal.ahmad.zeeshan as
Now I need that "afzaal.ahmad.zeeshan" as "afzaal", "ahmad", "zeeshan".
I need to split the query at "."
All-Star
52523 Points
15672 Posts
Re: String.Split
May 03, 2013 09:27 AM|oned_gk|LINK
Suwandi - Non Graduate Programmer
Contributor
2006 Points
725 Posts
Re: String.Split
May 03, 2013 09:48 AM|sanjayverma_mca|LINK
Hi ,
try this
Contributor
4010 Points
1926 Posts
Re: String.Split
May 03, 2013 10:38 AM|Afzaal.Ahmad.Zeeshan|LINK
Hehehe funny, but my mistake was that I was using " instead of '. That was the issue! Thanks everybody! :)
Contributor
4010 Points
1926 Posts
Re: String.Split
May 03, 2013 10:41 AM|Afzaal.Ahmad.Zeeshan|LINK
Just one more thing please, What is the function of Label1.Text here? Should I change it? And also, what will be the .Format() ?
All-Star
52523 Points
15672 Posts
Re: String.Split
May 03, 2013 10:49 AM|oned_gk|LINK
Suwandi - Non Graduate Programmer
Contributor
4010 Points
1926 Posts
Re: String.Split
May 03, 2013 10:52 AM|Afzaal.Ahmad.Zeeshan|LINK
I guess, thats possible in Web Forms only, because my page gave an error that Label1 is not present in your content!