I want to split a whatsapp chat backup text by date and keep the date as part of messages. I tried and couldn't achieve the exact result i want. If anyone can suggest me a way to achieve this, that would be a big help. (I don't know much about regex)
import re
chat = '27/01/2019, 08:58 - Member 01 created group "Python Lovers ❤️"
27/01/2019, 08:58 - You were added
19/03/2019, 19:29 - Member 02: Hello guys,,,
19/03/2019, 19:29 - Member 03: Hi there..'
regex = r"(\b\d+/\d+/\d+.*?(?=\b\d+/\d+/\d+|$)*)"
results = re.split(regex, chat)
print(results)
the above code does the job and keep the seperator as seperate item, but what i want it to be a part of its correponding message (item):
Current Result
['27/01/2019',
'08:58 - You were added',
'19/03/2019',
'19:29 - Member 02: Hello guys,,',
'19/03/2019',
'19:29 - Member 03: Hi there..']
WHAT I WANT
['27/01/2019, 08:58 - You were added',
'19/03/2019, 19:29 - Member 02: Hello guys',
'19/03/2019, 19:29 - Member 03: Hi there..']