formatSql = () => {
let sqlValue = $("#sql").val();
let keyword = "select from where and count group by orderby";
keyword = '(' + keyword.replace(/([\+\.\*\|\?\-\(\[\^\$])/g, '\\$1').replace(/\s+/g, '|') + ')';//把匹配关键字中的正则符转义
let patt = new RegExp(keyword, 'gi');
let str = sqlValue.replace(patt, function ($, $1) {
var upr = $1;
return upr.toUpperCase();
});
let formatteSqlValue = sqlFormatter.format(str);
$("#sql").val(formatteSqlValue);
this.setState({repsql: formatteSqlValue});
}