Created
October 21, 2024 18:20
-
-
Save X-Raym/d222bc5e0a92c2333d23b4dc912ab66e to your computer and use it in GitHub Desktop.
Python regex match to list / array
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 | |
str = "ab-ab" | |
regex = r"(\w+)\-(\w+)" | |
matches = re.search( regex, str ) | |
print( list(matches.groups()) ) | |
## ['ab', 'ab'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment