Regular expression to find URLs within a string

前端 未结 27 1992
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 14:18

Does anyone know of a regular expression I could use to find URLs within a string? I\'ve found a lot of regular expressions on Google for determining if an entire string is

27条回答
  •  旧时难觅i
    2020-11-22 14:45

    All of the above answers are not match for Unicode characters in URL, for example: http://google.com?query=đức+filan+đã+search

    For the solution, this one should work:

    (ftp:\/\/|www\.|https?:\/\/){1}[a-zA-Z0-9u00a1-\uffff0-]{2,}\.[a-zA-Z0-9u00a1-\uffff0-]{2,}(\S*)
    

提交回复
热议问题