I am currently working on a WhatsApp chat analyser and I have been trying to figure out the pattern for the authors and messages of the chat history but I am not successful.
I have a sample of the chat which looks like this:
08.03.22, 20:55 - Laura: Ja klingt gut :)
08.03.22, 21:00 - Anil: Wunderbar :)
What is the pattern, that could extract Laura , Anil into one list and Ja klingt gut :) , Wunderbar :) into another. For the dates and times I already found the pattern.
Thanks in advance.
>Solution :
If your messages are in a list.
v = ["08.03.22, 20:55 - Laura: Ja klingt gut :)",
"08.03.22, 21:00 - Anil: Wunderbar :)"]
import re
pattern = re.compile(r'- ([A-Za-z]*):([A-Za-z :)]*)')
names = [pattern.findall(x)[0][0] for x in v]
messages = [pattern.findall(x)[0][1] for x in v]
You can try the above code.