fork(2) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.*;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String s = "\"Test Line wo line break\"; \"Test Line \nwith line break\"\n\"Test Line2 wo line break\"; \"Test Line2 \nwith line break\"";
  11.  
  12. StringBuffer result = new StringBuffer();
  13. Matcher m = Pattern.compile("\"[^\"]*\"").matcher(s);
  14. while (m.find()) {
  15. m.appendReplacement(result, m.group().replaceAll("\\R+", ""));
  16. }
  17. m.appendTail(result);
  18. System.out.println(result.toString());
  19.  
  20. }
  21. }
Success #stdin #stdout 0.05s 2184192KB
stdin
Standard input is empty
stdout
"Test Line wo line break"; "Test Line with line break"
"Test Line2 wo line break"; "Test Line2 with line break"