Last active
July 3, 2020 14:30
-
-
Save dardanxhymshiti/24f460b330b388bfdf7d8722ada685e1 to your computer and use it in GitHub Desktop.
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
def get_text_within_brackets(text): | |
import re | |
pattern = r"[\(|\[|\{](.*?)[\)|\]|\}]" | |
list_of_findings = re.findall(pattern, text) | |
return list_of_findings | |
# Test | |
text = '''I was very surprised (and it's pretty hard to surprise me!)... He [Felix] is a gret friends of me...''' | |
get_text_within_brackets(text) | |
# [ "and it's pretty hard to surprise me!", 'Felix' ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment