如下:
/**
* 处理代码中的注释
* @param code code
*/
public String handleCode(String code){
// 处理:/* */
String reg = "/\\*(.|[\\r\\n])*?\\*/";
code = ReUtil.replaceAll(code, reg, StrUtil.EMPTY);
// 处理: //
reg = "/(\"([^\\\\\\\"]*(\\\\.)?)*\")|('([^\\\\\\']*(\\\\.)?)*')|(\\/{2,}.*?(\\r|\\n|$))|(\\/\\*(\\n|.)*?\\*\\/)/g";
code = ReUtil.replaceAll(code, reg, StrUtil.EMPTY);
return code;
}
完