JavaScript Regular Expression Validation Ip,url

Source: Internet
Author: User

Verify IP

function IsIP (ipstr) {var reg =/^ (\d{1,2}|1\d\d|2[0-4]\d|25[0-5]) \. ( \D{1,2}|1\D\D|2[0-4]\D|25[0-5]) \. (\d{1,2}|1\d\d|2[0-4]\d|25[0-5]) \. (\d{1,2}|1\d\d|2[0-4]\d|25[0-5]) $/g;return Ipstr.match (reg);}

The regular verification of this URL is comprehensive, it verifies that the situation includes IP, domain name, FTP, level two domain name, the domain name of the file, domain name plus port! User name, etc. information

function Isurl (str_url) {var Strregex = ' ^ ((https|http|ftp|rtsp|mms)?:/ /) ' + '? ([0-9a-z_!~* (). &=+$%-]+:)? [0-9a-z_!~* (). &=+$%-] [email protected])? ' FTP [email protected]+ ' ([0-9]{1,3}.) {3} [0-9] {1,3} '//IP url-199.194.52.184+ ' | '//Allow IP and domain (domain name) + ' ([0-9a-z_!~* ()-]+.) * '//Domain name-www.+ ' ([0-9a-z][0-9a-z-]{0,61})? [0-9a-z]. ' Two-level domain name + ' [a-z]{2,6} '//First domain-. com or. museum+ ' (: [0-9]{1,4})? '//Port-: 80+ ' ((/?) | '//a slash ' t requ Ired If there is no file Name+ ' (/[0-9a-z_!~* ().;?: @&=+$,%#-]+) +/?) $ '; var re=new RegExp (Strregex); if (Re.test (Str_url)) {return (true);} Else{return (FALSE);}}

  

JavaScript Regular Expression Validation Ip,url

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.