public static String wrapPropertiesString(String s) {\r
String ret = "({"\r
+ s.replaceFirst("^[({]+", "").replaceFirst("[})]+$", "")\r
- .replaceAll(":\\s*([^\"'\\s])([^,}]+)\\s*", ":\"$1$2\"") + "})";\r
+ .replaceAll("\\s*/\\*[\\s\\S]*?\\*/\\s*", "")\r
+ .replaceAll(":\\s*[\"']?([^;,]+)([,;]|$)[\"']?\\s*", ":'$1',")\r
+ .replaceFirst("[;,]$", "").replaceAll("\\s*[']+\\s*", "'")\r
+ + "})";\r
return ret;\r
}\r
\r
.wrapPropertiesString("{(border:'1px solid black')}"));
assertEquals("({border:'1px solid black'})", Properties
.wrapPropertiesString("({border:'1px solid black'})"));
+ assertEquals("({b:'a',c:'1',d:'url('adfafa')'})", Properties
+ .wrapPropertiesString("b: 'a'; c: 1, /*gg: aadf*/d: url('adfafa');"));
}
}