import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "^(Em\\s)?\\d{1,2}\\sde\\s\\w+\\sde\\s\\d{4}\\s\\d{1,2}:\\d{1,2}([^@]+@\\w+\\.\\w+\\.\\w+|,\\s\\sescreveu\\:)?";
final String string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n\n"
+ "5 de Abril de 2018 10:50, atendimento@teste.com.br (mailto:atendimento@teste.com.br) escreveu:teste\n\n"
+ "Em 5 de Abril de 2018 10:30, atendimento@teste.com.br (mailto:atendimento@teste.com.br) escreveu:resposta atendimento\n\n"
+ "-----------------------------------------------------------\n\n"
+ "Olá, como vai?\n\n"
+ "10 de abril de 2018 09:49\n\n"
+ "10 de abril de 2018 09:49, escreveu:\n\n"
+ "Em 10 de abril de 2018 09:49\n\n"
+ "Em 10 de abril de 2018 09:49, escreveu:\n\n"
+ "> Resposta atendimento\n"
+ ">\n"
+ ">\n"
+ "> 10 de Abril de 2018 09:48, \"erick zanetti\" > escreveu:\n"
+ ">\n"
+ ">\n"
+ "> Olá, erick,\n"
+ "> A data de entrega do seu trabalho Lista Vetores\n"
+ "> é\n"
+ "> amanhã. Você deseja entregá-lo?\n"
+ ">\n"
+ ">\n"
+ "> Lista Vetores\n"
+ "> Prazo: 7 de abr\n"
+ "> ABRIR\n"
+ ">\n"
+ "> Se você não quiser receber e-mails do Sala de aula, cancele sua inscrição\n"
+ "> .\n"
+ ">\n"
+ ">\n"
+ ">";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
while (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