URL Validation REGEX - URL just valid with http://

后端 未结 5 1139
梦谈多话
梦谈多话 2020-12-14 17:50

How it works

I have an input field to enter the URL of a Website and i wanna check it and if the URL is OK i will give the inputfield a class(\"vali

5条回答
  •  执念已碎
    2020-12-14 18:27

    ^http(s?):\/\/(www\.)?(((\w+(([\.\-]{1}([a-z]{2,})+)+)(\/[a-zA-Z0-9\_\=\?\&\.\#\-\W]*)*$)|(\w+((\.([a-z]{2,})+)+)(\:[0-9]{1,5}(\/[a-zA-Z0-9\_\=\?\&\.\#\-\W]*)*$)))|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}(([0-9]|([1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]+)+)(\/[a-zA-Z0-9\_\=\?\&\.\#\-\W]*)*)((\:[0-9]{1,5}(\/[a-zA-Z0-9\_\=\?\&\.\#\-\W]*)*$)*))$
    In this http is mandatory and it can take port and sub resources also.
    e.g http://example.com
        https://example.qwerty.com/id
        https://example.com:8989
        http://example.qwerty.com:8989/id
        https://10.1.1.1/id
        https://10.1.1.1:9090/id
    

提交回复
热议问题