Match http links in strings using Python regular expressions. The main difficulty is representing the pattern of http links with a regular expression.
import re pattern = (r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+') # Matching patterns string = 'Its after 12 noon, do you know where your rooftops are? /NYCRooftops ' url = (pattern,string) print url >>['/NYCRooftops']
Above this Python regular expression to match the http link in the string method is all that I have shared with you, I hope to be able to give you a reference, and I hope you will support me more.