Last active
December 16, 2021 12:19
-
-
Save xjxckk/4376ba5ddc0cfa480e2c349270664eca to your computer and use it in GitHub Desktop.
Regex positive lookbehind to capture string after prefix (Python)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import regex | |
url = 'https://gfycat.com/HeftyHonoredHadrosaurus' | |
prefix = 'https://gfycat.com/' | |
# https://gfycat.com/HeftyHonoredHadrosaurus to HeftyHonoredHadrosaurus | |
slug = regex.search(rf'(?<={prefix})\w+', url).group() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment