What is the RFC compliant and working regular expression to check if a string is a valid URL

前端 未结 4 1392
无人及你
无人及你 2020-12-06 10:04

There is question by the almost the same name already: What is the best regular expression to check if a string is a valid URL

I don\'t understand this stackoverflow

4条回答
  •  温柔的废话
    2020-12-06 10:26

    After reading RFC 3986, I have to say I was wrong. That regexp is fully working (that I know). First mistake I had was syntax of IPv6 addresesses, they are put around [], and second was about example.org: (note trailing double dot :). But as the RFC says scheme can have dots in it, so it's also valid.

    So that's valid RFC way to do it, but people will usually (as I will) need to modify it to only accept some schemas.

提交回复
热议问题