fork download
  1. import java.util.regex.*;
  2. import java.util.*;
  3. import java.lang.*;
  4. import java.io.*;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String s = "\"some\" \"other string\"";
  11. System.out.println(removeQuotes(s));
  12. }
  13. public static String removeQuotes(String str) {
  14. Pattern pattern = Pattern.compile("^['\"](.*)['\"]$");
  15. Matcher matcher = pattern.matcher(str);
  16. if (matcher.find()) {
  17. return matcher.group(1);
  18. } else {
  19. return str;
  20. }
  21. }
  22. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
some" "other string