fork download
  1. // Extrair grupos com regex - http://pt.stackoverflow.com/q/191280/53463
  2. import java.util.regex.Matcher;
  3. import java.util.regex.Pattern;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. final String regex = "^\\{([\\dA-F]{8}(?:-[\\dA-F]{4}){4}[\\dA-F]{8})\\} \\| (\\d{2}/\\d{2}/\\d{4}|\\d{4}-\\d{2}-\\d{2})";
  10. final String linha = "{E4AE5831-548B-4429-CB99-2429334A6348} | 16/03/2017 00:59:35 | [ColetaCPFVerificaColetaInicialReportCode] : [O seguinte prompt serĂ¡ vocalizad";
  11.  
  12. final Pattern p = Pattern.compile(regex);
  13. final Matcher m = p.matcher(linha);
  14.  
  15. if(m.find()){
  16. System.out.println(m.group(1));
  17. System.out.println(m.group(2));
  18. }
  19. }
  20. }
Success #stdin #stdout 0.07s 3359744KB
stdin
Standard input is empty
stdout
E4AE5831-548B-4429-CB99-2429334A6348
16/03/2017