# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"\[[^\]]*\]\s*[^\[]*\s*\[[^\]]*\]\([^\)]*\):\s*"
test_str = ("morning lendhu kinda troubles\n"
"thatha wanted me to buy cake for him\n"
"I went and spent 30 mins extra to get cake\n"
"[12:58, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): by the time I got home neighbor came so spoke with him for the first time in 10 years\n"
"[12:58, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): thatha spit the cake so I felt a lil bad\n"
"[12:59, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): nurse told me don't get cake he'll react negatively\n"
"[12:59, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): but I got because I felt it was one of his last and small wish\n"
"[12:59, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): so I thought I'll go to office and poop\n"
"[12:59, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): but it was late so I went upstairs to poop\n"
"[12:59, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): adhukkula pati called me 10 times about why I didn't go to office\n"
"[13:00, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): got so mad but controlled myself and went to office\n"
"[13:08, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): Adhukkula she has called perimma and cried saying he's not taking phone\n"
"[13:08, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): Within 6 minutes\n"
"[13:09, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): And then I came to office adhukkula a meeting got booked (good news) but I need to hire faster and need to be able to pay them consistently (because I'm afraid of losing clients too)\n"
"[13:09, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): And then balaji called and I was like I'm a lil worried about u not working on yourself\n"
"[13:10, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): And he started crying saying I can't speak normally to you at all I'm lonely\n"
"[13:10, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): Adhulkula phone got switched off\n"
"[13:10, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): Now I'm uploading all contacts to CRM to calm down my anxiety and get ready for meetings at 4 and 10:30\n"
"[13:10, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): Thideer nu somedays are like this stressful and some days are like super peaceful\n"
"[13:11, 30/03/2023] Bharadwaj Giridhar from [inboxpirates.net](http://inboxpirates.net/): Then the fight with vaishnav also is kinda bothering me but I don't have the time to talk with her")
matches = re.search(regex, test_str)
if matches:
print ("Match was found at {start}-{end}: {match}".format(start = matches.start(), end = matches.end(), match = matches.group()))
for groupNum in range(0, len(matches.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = matches.start(groupNum), end = matches.end(groupNum), group = matches.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html