Regex to match all valid links

后端 未结 2 1159
野性不改
野性不改 2021-02-06 18:44

In regards to this: http://stackoverflow.uservoice.com/pages/general/suggestions/103227-parser-does-not-match-all-valid-urls is this regex adequate or will it need to be refined

2条回答
  •  死守一世寂寞
    2021-02-06 18:58

    I guess SO blocks comments after a while? localshred's answer is great, except for a missing wildcard and unescaped periods:

        /^([^:]+):\/\/([-\w\._]+)(\/[-\w\._]*\?(.+)?)?$/ig
                                            ^-- wildcard
                            ^
        we dont want to match everything ^
    

提交回复
热议问题