现在的位置: 首页 > 综合 > 正文

sql脚本和js中使用字符串的处理

2013年01月11日 ⁄ 综合 ⁄ 共 232字 ⁄ 字号 评论关闭
// 处理单引号    
public static String getSQL(String s) {
        if (s != null) {
            s = s.replaceAll("'", "''");
        }
        return s;
    }
    
// 处理单引号和双引号,例如:"Test"问题'
    public static String getScriptString(String s) {
        if (s != null) {
            s = s.replaceAll("/'", "////'").replaceAll("/"", "/////"");
        }
        return s;
    }

抱歉!评论已关闭.