fork download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. private static String removeComments(String input) {
  7. return input.replaceAll("'[^']+'", "");
  8. }
  9.  
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. System.out.println( removeComments("1+4 'sum'").equals("1+4 ") );
  13. System.out.println( removeComments("this 'is not a comment").equals("this 'is not a comment") );
  14. System.out.println( removeComments("1+4 'sum' 'unclosed comment").equals("1+4 'unclosed comment") );
  15. }
  16. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
true
true
true