如何从两个点之间的文本框中获取文本
例如,我只想从两个点之间的文本框中获取文本。 万维网。 abc.org 。 H
i just want to get a text from textbox that is betwen two dots for example. www. abc.org . h
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在 C#
从文本框中获取字符串:
但是请使用 try 和 catch ;)
in C#
Get String From Textbox:
But please, use try and catch ;)
我认为你需要更具体地回答你的问题。 现在,如果您只是想提取地址的中间部分,类似下面的内容应该可以完成这项工作:
You'll need to be a bit more specific with your question I think. Now, if you're just looking to extract the middle part of the address, something like the following should do the job:
这与您的要求一样具体吗?
它是否只适用于 www.SOMESITE.com,
其他 TLD 扩展名(如 .net、.org、.co.uk、.ie 等)怎么样?
其他子域(例如 www2.、api.、news.)又如何呢? ETC...
没有子域的域(例如 google.com、theregister.co.uk、bit.ly)怎么样?
如果这很简单,就像您的要求一样,
但
我感觉您没有考虑清楚或完全解释您的要求。
如果是更复杂的场景,您可能需要查看正则表达式。
Is that as specific as your requirement is?
does it only have to work for www.SOMESITE.com
what about other tld extensions like, .net, .org, .co.uk, .ie etc...
what about other subdomains like, www2., api., news. etc...
what about domains with no subdomain like, google.com, theregister.co.uk, bit.ly
if that's a simple as your requirement is,
then
though I've a feeling you haven't thought through or fully explained your requirements.
If it is a more complex scenario, you might want to look at Regular expressions.
字符串干草堆=“www.google.com”;
字符串针=“谷歌”;
我重新阅读了带有评论的帖子,我可以看到您可能不知道要提取哪个单词...我认为第一个答案就是您正在寻找的答案。
如果您有特殊需要,还可以使用正则表达式从 URL 中提取域名。
像这样的事情:
string haystack= "www.google.com";
string needle = "google";
I re-read the post with comments I can see that you probably don't know what word you are going to extract... I think the first answer is the one that you are looking fore.
There's also regular expressions for extracting the domainname out of a url if that is your specific need.
Something like this: