正则表达式匹配URL或者⽹址
正则表达式(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?
匹配regxlib/Default.aspx | electronicset/electronics/0-6342366-8-8994967-1.html 不匹配www.yahoo
正则表达式^\\{2}[\w-]+\\(([\w-][\w-\s]*[\w-]+[
]?$)|([\w−][ ]?$))
匹配\\server\service | \\server\my service | \\serv_001\service$不匹配\\my server\service | \\server\ service | \\server$\service
正
则表达式^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%$\-]+)*@)?((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}| [1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)
\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.[a-zA-Z]{2,4})(\:[0-9]+)?(/[^/][a-zA-Z0-9\.\,\?\'\\/\+&%$#\=~_\-@]*)*$
匹
配
www.sysrage | 64.81.85.161/site/file.php?cow=moo's |ftp://user:pass@host:123
不
匹
配
sysrage
正则表达式^([a-zA-Z]\:|\\\\[^\/\\:*?"<>|]+\\[^\/\\:*?"<>|]+)(\\[^\/\\:*?"<>|]+)+(\.[^\/\\:*?"<>|]+)$
匹配c:\ | \\server\ | \\server\shared\Test.t
不匹配c:\Test | \\server\shared | \\server\shared\Test.?
正
则表达式^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}| [1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\. (com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/(|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*
匹
配
site/dir/file.php?var=moo | localhost |ftp://user:pass@site:21/file/dir
正则匹配方法不
匹
配
site | site/dir//
正则表达式^([a-zA-Z]\:)(\\[^\\/:*?<>"|]*(?<![ ]))*(\.[a-zA-Z]{2,6})$
匹配C:\di___r\ | c:\
不匹配c:\dir\
正则表达式^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$
匹配regexlib | this.is.a.museum | 3com
不匹配notadomain- | helloworld.c | .
正则表达式^(((ht|f)tp(s?))\://)?(www.|[a-zA-Z].)[a-zA-Z0-9\-\.]+\.(com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk)(\:[0-9]+)*(/(|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*匹配www.blah:8103 | www.blah/blah.asp?sort=ASC |www.blah/blah.htm#blah
不匹配www.state.ga | www.blah.ru
正
则
表
达
式
\b(([\w-]+://?|www[.])[^\s()<>]+(?:[\w\d]+|([^[:punct:]\s]|/)))
匹配foo/blah_blah | foo/blah_blah/ | (Something like foo/blah_blah) | foo/blah_blah_(wikipedia) | (Something like
foo/blah_blah_(wikipedia)) | foo/blah_blah. |foo/blah_blah/. | <foo/blah_blah> | <foo/blah_blah/>| foo/blah_blah, | p=364. | ?df.ws/123 | rdar://1234 | rdar:/1234 | userid:password@example:8080 |userid@example | userid@example:8080 |userid:password@example
不
匹
配
ample | no_proto_or_ws | /relative_resource.php
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论