fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.regex.Pattern;
  7. import java.util.regex.Matcher;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14.  
  15. String line = "COOP:166657,'NEW IBERIA AIRPORT ACADIANA REGIONAL LA US',200001,177,553";
  16. Pattern pattern = Pattern.compile("^(.*?):(.*?),'(.*?)',(.*?),(.*?),(.*?)$", Pattern.DOTALL | Pattern.MULTILINE);
  17.  
  18. // Get matcher on this String.
  19. Matcher m = pattern.matcher(line);
  20.  
  21. // If it matches, get and display group values.
  22. if (m.matches()) {
  23. String part1 = m.group(1);
  24. String part2 = m.group(2);
  25. String part3 = m.group(3);
  26. String part4 = m.group(4);
  27. String part5 = m.group(5);
  28. String part6 = m.group(6);
  29.  
  30.  
  31. System.out.println(part1);
  32. System.out.println(part2);
  33. System.out.println(part3);
  34. System.out.println(part4);
  35. System.out.println(part5);
  36. System.out.println(part6);
  37. }
  38. }
  39. }
Success #stdin #stdout 0.09s 320320KB
stdin
Standard input is empty
stdout
COOP
166657
NEW IBERIA AIRPORT ACADIANA REGIONAL LA US
200001
177
553