如何在URL中添加字符串 [英] How to add string in url

查看:424
本文介绍了如何在URL中添加字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说网址是http://www.mysite.com/funny/vacation/pictures,我想在www.mysite.com和funny之间拆分并添加真正的单词.
因此,该网址现在为http://www.mysite.com/really/funny/vacation/pictures.这将通过按钮单击事件完成,并且将新的url发送到新的文本框,而且它不能像字符串link ="really";带有+链接,因为从假期开始会有所变化.我已经尝试并在上个星期搜索google来解决此问题,并且无法完全弄清楚任何帮助将不胜感激.

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.

推荐答案

我不太确定我理解了后续行动,但仅仅是我的脑海,也许是这样的事情?
I''m not quite sure i understood the followup but just atop of my head, something like this maybe?
string temp = "http://www.mysite.com/funny/vacation/pictures";
string new_word = "really";
string last = temp.Replace("funny", new_word + "/funny");


或者,您可以使用string.Split()或正则表达式或string.Insert().如果您对问题进行了更干净的描述,将会更容易.

问候,
AnılYıldız.


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.


很棒,它获得了我需要的链接,但以该链接结束,现在我该如何添加链接的Vacation/pictures部分,但实际上不添加那些页面,因为这些页面会改变.使用也许像lastindex.我一直在尝试使用link.replace,但是什么也没做,请关闭以感谢您的任何帮助
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


,该帮助与urnname完美地结合使用了该代码.先生
that worked perfectly used that code with urnname.replace code based on ur code and worked perfectly thank you sir


这篇关于如何在URL中添加字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆