Web服务URL的正则表达式 [英] Regular expressions for Web service URL

查看:193
本文介绍了Web服务URL的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我创建了一个Web服务" https:// servername:443 / dir1 / file.asmx "。我需要验证这个网址。条件是端口协议可以是"http"ot"https"。


端口可以不同。 servername可以是"name"或"Ip"。路径中可以有更多"子目录",如" https://127.0.0.1:443/dir1/dir2/file.asmx "。



任何人都可以为我提供正则表达式来正确验证吗?

解决方案

有一些很棒的正则表达式模式资源...

http://regexlib.com/Search.aspx http:/ /social.msdn.microsoft.com/forums/en-US/regexp/thread/12010a1e-4d77-404e-9bf3-d93c9797fdce/



这里是一种可能有帮助的模式...

^(http | https)\ :// [A-ZA-Z0-9\-\。] + \ [A-ZA-Z] {2,3}。(:[A-ZA-Z0-9] *)/? ([A-ZA-Z0-9\-\._\ \,\'/ \\\ +&安培;安培;%\

#\ =〜])*



你可能需要调整它以使其完全适合。


Hi,

I have created a web service "https://servername:443/dir1/file.asmx" . I need to validate this url.  The condition is port protocol can be "http" ot "https".

Port can be different. And servername can be "name" or "Ip". There can be more "subdirectory" in the path like "https://127.0.0.1:443/dir1/dir2/file.asmx".

 

Could anyone provide me regular expression for this url to validate properly?

解决方案

There are some great Regex pattern resources at...

http://regexlib.com/Search.aspx and
http://social.msdn.microsoft.com/forums/en-US/regexp/thread/12010a1e-4d77-404e-9bf3-d93c9797fdce/ 
...

Here is a pattern that might help...

^(http|https)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\


#\=~])*




... You might have to tweak it to fit exactly.


这篇关于Web服务URL的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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