Last active
October 5, 2024 17:49
-
-
Save dheerapat/46c939898c3d299e1a9d74f5f8daa198 to your computer and use it in GitHub Desktop.
python regex example
This file contains hidden or 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 re | |
| txt = """<|python_tag|><function=spotify_song_artist>{"n": "[\"BIRDS OF A FEATHER\", \"Espresso\", \"Please Please Please\", \"Not Like Us\", \"Gata Only\"]"}</function>""" | |
| x = re.search("<function=(\w+)>(.*?)</function>", txt) | |
| if x: | |
| print("YES! We have a match!") | |
| print(x.group()) | |
| else: | |
| print("No match") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment