fork(1) 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.*;
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12.  
  13. String line = "\"USE CODE \"\"Gef, sdf\"\" FROM 1/7/07\", Delete , Hello , How are you ? , ";
  14. String line2 = "Test asda ds asd, tesat2 . test3";
  15. Pattern pattern = Pattern.compile("(?:\"[^\"]*(?:\"\"[^\"]*)*\"|[^,])+");
  16. Matcher matcher = pattern.matcher(line);
  17. if (matcher.find()){
  18. System.out.println(matcher.group(0));
  19. }
  20. Matcher matcher2 = pattern.matcher(line2);
  21. if (matcher2.find()){
  22. System.out.println(matcher2.group(0));
  23. }
  24. }
  25. }
Success #stdin #stdout 0.11s 320512KB
stdin
Standard input is empty
stdout
"USE CODE ""Gef, sdf"" FROM 1/7/07"
Test asda ds asd