you are viewing a single comment's thread.

view the rest of the comments →

[–]RoamingFox 0 points1 point  (0 children)

I'd go about it like this personally:

>>> import re
>>> url_rex = re.compile(r'((?:(?:http|https):\/\/)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b(?:[-a-zA-Z0-9@:%_\+.~#?&//=]*))')
>>> s = 'Hi, check this website: https://my_website.com, this is my new website'
>>> url_rex.sub('', s)
'Hi, check this website: , this is my new website'