Skip to content

Instantly share code, notes, and snippets.

@ultrafunkamsterdam
Created June 21, 2021 13:50
Show Gist options
  • Save ultrafunkamsterdam/69467b5a725020d7fcfdd1d072b2dbff to your computer and use it in GitHub Desktop.
Save ultrafunkamsterdam/69467b5a725020d7fcfdd1d072b2dbff to your computer and use it in GitHub Desktop.
python regex url pattern that actually works
import re
REGEX_URL = re.compile(r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment