In this article, we will need to accept a string and check if the string contains any url. If the url is present in the string, we will say the url is found or not and print the corresponding url present in the string. We'll use Python's regex concept to solve the problem.
Input: string = 'My Profile: https://auth.python.engineering/user/Chinmoy%20Lenka / articles in the portal of http:// www.python.engineering / 'Output: URLs: [' https:// auth.python.engineering / user / Chinmoy% 20Lenka / articles', 'http://www.python.engineering / '] Input: string =' I am a blogger at https:// python.engineering' Output: URL: ['https:// python.engineering']
To find a URL in a given string, we used the Output:
# Python code to find URL from input string
# Using regular expression
# findall () was used
# with valid URL conditions in line
re.findall ('http [s] ?:
Z] | [
] | [$
_ @. & amp;
(),] | (?:
' My Profile: https:
the portal of http:
" Urls: "
, Find (string))
Urls: ['https:// auth.python.engineering / user / Chinmoy% 20Lenka / articles',' http://www.pythonengineering. org / ']
I remember one day, when I was about 15, my little cousin had come over. Being the good elder sister that I was, I spent time with her outside in the garden, while all the adults were inside having a ...
Computer Age Statistical Inference: Algorithms, Evidence, and Data Science (Institute of Mathematical Statistics Monographs, Series Number 6). The twenty-first century has seen a breathtaking expan...
A recipe for having fun and getting things done with the Raspberry Pi ...
Python for Programmers: with Big Data and Artificial Intelligence Case Studies This book, written for programmers with a high-level experience in another language, uses how-to instructions to teach...