import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "\\[[^\\]]*\\]\\s*[^\\[]*\\s*\\[[^\\]]*\\]\\([^\\)]*\\):\\s*";
final String string = "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";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(string);
if (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
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 Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html