fork(4) download
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  3.  
  4. class Ideone
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. String str = "{abc:\"def\", ghi:\"jkl\"}";
  9. String regex = "(?:[{ ,])(\\w+)(?!\")";
  10. System.out.println(str.replaceAll(regex, "\\\"$1\\\""));
  11. }
  12. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
"abc":"def","ghi":"jkl"}