Last active
July 31, 2018 10:27
-
-
Save yaronv/6eec11cb1fb3efc79c0b508f03f13bd4 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 ismessage(self, str): | |
patterns = { | |
"pattern1":r'(\d{1,2}/\d{1,2}/\d{2,4}),\s+(\d{2}:\d{2})\s*-\s*(\w*\s*\w*)\s*:\s*(.*)' | |
} | |
for key in patterns: | |
r = re.search(patterns[key], str) | |
if r != None: | |
date = r.group(1) | |
time = r.group(2) | |
name = r.group(3).lower() | |
message = r.group(4).translate(str.maketrans('','',string.punctuation)) | |
return [date, time, name, message] | |
return None | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment