操作sqlite3数据库的时候,一些特殊字符需要进行转义处理,直接上代码
/** * @description 转义sqlite3中的特殊字符 * @param str * @returns */ replaceSpecialCharacter(str: string) { str = str.replaceAll('/', '//') str = str.replaceAll('[', '/[') str = str.replaceAll(']', '/]') str = str.replaceAll('%', '/%') str = str.replaceAll('&', '/&') str = str.replaceAll('_', '/_') str = str.replaceAll('(', '/(') str = str.replaceAll(')', '/)') str = str.replaceAll("'", "''") return str }