URL Validator的正则表达式 [英] Regular expression for URL Validator
问题描述
Hello All,
我的正则表达式有问题。我需要验证以下网址
http://50.244.41.23/ 或 http:// myserver /
我使用了以下表达式
正则表达式urlRx = new 正则表达式( @ (http | https): //([0-9] *),RegexOptions.IgnoreCase);
正则表达式urlRx = 新正则表达式( @ (HTTP | HTTPS)://(?\b(:\d {1,3} \){3} \d {1,3} \b。)跨度>,RegexOptions.IgnoreCase);
两者都在一定程度上正在发挥作用,但它没有达到目的。它为以下字符串提供了成功,但我希望表达式对这些字符串失败..
http://50.244.41.23 \
http://256.244.41.23/
http://256.244.41.23.123/
有人可以帮助为上面的url创建一个apt正则表达式验证。
谢谢
Sebastian
文字:我验证:
< html xmlns = http://www.w3.org/1999/xhtml >
< head >
< 跨度> 标题 > 有或没有http的网址的正则表< ; / title >
< script type = text / javascript < span class =code-attribute> src = http://code.jquery.com/ jquery-1.8.2.js > < / script >
< script 类型 = text / javascript >
( function (){
(' #btnValidate')。click( function (){
var txt =
Hello All,
I have an issue with regular expression. I need to validate for the following url
http://50.244.41.23/ or http://myserver/
I have used following expressions
Regex urlRx = new Regex(@"(http|https)://([0-9]*)", RegexOptions.IgnoreCase);
Regex urlRx = new Regex(@"(http|https)://(\b(?:\d{1,3}\.){3}\d{1,3}\b)", RegexOptions.IgnoreCase);
Both are working up to an extent, But it doesn't serve the exact purpose. It gives success for the following strings, But i want the expression to fail for such strings..
http://50.244.41.23\
http://256.244.41.23/
http://256.244.41.23.123/
Can someone help to create an apt regex validation for the above url.
Thanks
Sebastian
Text this: Verified by me:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Regex for urls with or without http Page</title> <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script> <script type="text/javascript">
(function() {
('#btnValidate').click(function() { var txt =
这篇关于URL Validator的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!