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 a URL but I need to be able to search an entire string for URLs. For example, I would like to be able to find www.google.com
and http://yahoo.com
in the following string:
Hello www.google.com World http://yahoo.com
I am not looking for specific URLs in the string. I am looking for ALL of the URLs in the string which is why I need a regular expression.
Это просто просто.
Использование этот шаблон: \b((ftp|https?)://)?([\w-\.]+\.(com|net|org|gov|mil|int|edu|info|me)|(\d+\.\d+\.\d+\.\d+))(:\d+)?(\/[\w-\/]*(\?\w*(=\w+)*[&\w-=]*)*(#[\w-]+)*)?
Это соответствует любой ссылке, содержит:
Разрешенные протоколы: http, https и ftp
Позволенные Домены: *.com, *.net, *.org, *.gov, *.mil, *.int, *.edu, *.info и *.me ИЛИ разрешенные порты IP
: верный
Позволенные Параметры: верный
Позволенные Хеши: верный