探知,不断发现
探知不断发现

ValidationExpression="http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?" can not work

"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?" this regular expression is given by Visuial studio. we use that to valid Url format.

But if the the url contains "+" symbol. we will see the an error message.

 

We can change the regular expression to "http(s)?://([\w-]+\.)+[\w-]+(/[\w-+ ./?%&=]*)?"

or "(http|https):(?://(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?|(/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?"

posted on 2013-11-29 09:10  lovebanyi  阅读(2267)  评论(0编辑  收藏  举报