Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Say that the url is http://www.mysite.com/funny/vacation/pictures , I want to split and add the word really between www.mysite.com and funny.
So that the url is now http://www.mysite.com/really/funny/vacation/pictures. this would be done with a button click event and the new url sent to a new text box plus it cant be like string link = "really"; with a + link because from vacation on will change. I have tried and search google for the last week on this issue and cant quite figure out any help would be greatly appreciated.
Posted

I'm not quite sure i understood the followup but just atop of my head, something like this maybe?
C#
string temp = "http://www.mysite.com/funny/vacation/pictures";
string new_word = "really";
string last = temp.Replace("funny", new_word + "/funny");

Or you could use string.Split() or regular expressions or string.Insert(). It would be easier if you have provided a cleaner description of the problem.

Regards,
Anıl Yıldız.
 
Share this answer
 
v2
great that gets the link in that i need but ends with that link now how do I add the vacation/pictures part of the link but not really those pages because the pages will change. using maybe like lastindex. I have been trying to use link.replace but that does nothing please so close thanks for any help
 
Share this answer
 
that worked perfectly used that code with urnname.replace code based on ur code and worked perfectly thank you sir
 
Share this answer
 
Comments
Anıl Yıldız 2-Jun-10 7:34am    
Glad i could help. Happy coding!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900