Example:
Input:
"learn python programming at https://www.includehelp.com/"
Output:
https://www.includehelp.com/
Python program to print URL using string
We will find the URL from the string using the regular expression which is made to accept URLs from the given strings.
We will use the findall() method from python's RE library.
Syntax:
findall(regex, string)
Regular expression to find the URL of a string
(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))
This large expression checks for all possible combinations of the URL. starting from character followed by http_: … and then . followed by the top level domain.
Program to print URL from the string
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer