Javascript URL validation regex

前端 未结 3 1067
甜味超标
甜味超标 2020-12-20 22:32

I had the following url validation regex:

/(ftp|https?)://[^ \"]+$/

This is from the ref: Regular expression for URL validation (in JavaScript)

This

3条回答
  •  一个人的身影
    2020-12-20 23:34

    I built this regex IP and DNS validation for javascript.

    /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?((([a-z0-9])*[:]){1}|(([a-z0-9])*[.]){1}|(([0-9]){1,3}([.]|[:])){3}(([0-9]){1,3}[:]){1})([a-z]{2,5}|[0-9]{1,5})([.]([a-z0-9]){1,3})?(\/.*)?$/
    

提交回复
热议问题