UE-行文-js-20141125

页面导航:首页 > 网络编程 > JavaScript > UE-行文-js-20141125

UE-行文-js-20141125

来源: 作者: 时间:2016-02-05 11:06 【

function Trim(str){ 把str首尾的空 26684;去掉 var temp1 = str replace( (^ s*)|( s*$) g, ); 把str首尾的单引号去掉 var temp2 = temp1 replace( (^ *)|( *$) g, );
function Trim(str)
{
//把str首尾的空格去掉
var temp1 = str.replace(/(^\s*)|(\s*$)/g, "");
//把str首尾的单引号去掉
var temp2 = temp1.replace(/(^'*)|('*$)/g, "");
//把str首尾的双引号去掉
var temp3 = temp2.replace(/(^"*)|("*$)/g, "");
return temp3;
}
//数组分组
function count_str(text_all,str_f)
{
var result = "";
result = text_all.split(str_f);
//return result.length - 1;
return result;
}
UltraEdit.activeDocument.findReplace.regExp = true;
var str_f = "^db";
var str_s = "^select";


//UltraEdit.activeDocument.bottom(); //跳转到文件结尾。


//==mongo.find==
UltraEdit.document[0].write("\n===========\n")
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.find(str_f); //查找字符串 str_f
while (UltraEdit.activeDocument.isFound()) //如果找到要查询的字符串,则执行下面程序
{
UltraEdit.activeDocument.selectLine();
line = UltraEdit.activeDocument.selection;
//UltraEdit.messageBox("find: "+line);
//var array = line.split(":"); //分成数组
var array = count_str(line,":");
var arr2 = array[0].split("{");
var arr3 = array[1].split("}");
var arr4 = arr2[0].split(".");
//UltraEdit.messageBox(arr4[1]+","+arr2[1]+","+arr3[0]);
var tab_name = arr4[1];
var key_name2 = arr2[1];
var key_name = Trim(key_name2)
var key_value2 = arr3[0];
var key_value = Trim(key_value2)
var Filed_0 = 'db.'+tab_name+'.find({"'+key_name+'":"'+key_value+'"},{"logicalDel":1}).pretty()';
//var Filed_1 = 'db.'+db_name+'.remove({"'+key_name+'":"'+key_value+'"})';
//var Filed_2 = 'db.'+tab_name+'.update({"'+key_name+'":"'+key_value+'"},{$set:{"logicalDel":NumberInt(1)}})';
//UltraEdit.messageBox(Filed_0+"\n"+Filed_1);
//UltraEdit.messageBox(Filed_2);
UltraEdit.document[0].write(Filed_0+"\n");
//UltraEdit.document[0].write(Filed_2+"\n")
UltraEdit.activeDocument.findReplace.find(str_f);
}
UltraEdit.document[0].write("\n===========\n")
//==mongo.update==
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.find(str_f); //查找字符串 str_f
while (UltraEdit.activeDocument.isFound()) //如果找到要查询的字符串,则执行下面程序
{
UltraEdit.activeDocument.selectLine();
line = UltraEdit.activeDocument.selection;
//UltraEdit.messageBox("find: "+line);
//var array = line.split(":"); //分成数组
var array = count_str(line,":");
var arr2 = array[0].split("{");
var arr3 = array[1].split("}");
var arr4 = arr2[0].split(".");
//UltraEdit.messageBox(arr4[1]+","+arr2[1]+","+arr3[0]);
var tab_name = arr4[1];
var key_name2 = arr2[1];
var key_name = Trim(key_name2)
var key_value2 = arr3[0];
var key_value = Trim(key_value2)
//var Filed_0 = 'db.'+tab_name+'.find({"'+key_name+'":"'+key_value+'"},{"logicalDel":1}).pretty()';
//var Filed_1 = 'db.'+db_name+'.remove({"'+key_name+'":"'+key_value+'"})';
var Filed_2 = 'db.'+tab_name+'.update({"'+key_name+'":"'+key_value+'"},{$set:{"logicalDel":NumberInt(1)}})';
//UltraEdit.messageBox(Filed_0+"\n"+Filed_1);
//UltraEdit.messageBox(Filed_2);
//UltraEdit.document[1].write(Filed_0+"\n");
UltraEdit.document[0].write(Filed_2+"\n")
UltraEdit.activeDocument.findReplace.find(str_f);
}


//==.select==
UltraEdit.document[0].write("\n===========\n")
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.find(str_s); //查找字符串 str_f
while (UltraEdit.activeDocument.isFound()) //如果找到要查询的字符串,则执行下面程序
{
UltraEdit.activeDocument.selectLine();
line = UltraEdit.activeDocument.selection;
//UltraEdit.messageBox("find: "+line);
var arr = count_str(line," ");
//UltraEdit.messageBox(arr[3]+","+arr[5]);
var table_name=Trim(arr[3]);
var arr2 = count_str(arr[5],"=");
//UltraEdit.messageBox(arr2[0]+","+arr2[1]);
var Column_name =Trim(arr2[0]);
var Column_value2 =Trim(arr2[1]);
var Column_value =count_str(Column_value2,"\"")
var Filed_4 = 'select * from '+table_name+' where '+Column_name+'="'+Column_value[0]+'"\\G';
//UltraEdit.messageBox(Filed_4);
UltraEdit.document[0].write(Filed_4+"\n")
UltraEdit.activeDocument.findReplace.find(str_s);
}
//==mysql.update==
UltraEdit.document[0].write("\n===========\n")
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.find(str_s); //查找字符串 str_f
while (UltraEdit.activeDocument.isFound()) //如果找到要查询的字符串,则执行下面程序
{
UltraEdit.activeDocument.selectLine();
line = UltraEdit.activeDocument.selection;
//UltraEdit.messageBox("find: "+line);
var arr = count_str(line," ");
//UltraEdit.messageBox(arr[3]+","+arr[5]);
var table_name=Trim(arr[3]);
var arr2 = count_str(arr[5],"=");
//UltraEdit.messageBox(arr2[0]+","+arr2[1]);
var Column_name =Trim(arr2[0]);
var Column_value2 =Trim(arr2[1]);
var Column_value =count_str(Column_value2,"\"")
var Filed_4 = 'update '+table_name+' set LogicalDel=1 where '+Column_name+'="'+Column_value[0]+'";';
//UltraEdit.messageBox(Filed_4);
UltraEdit.document[0].write(Filed_4+"\n")
UltraEdit.activeDocument.findReplace.find(str_s);

}
UltraEdit.document[0].write("commit;\n")
Tags:

相关文章

    文章评论

    最 近 更 新
    热 点 排 行
    Js与CSS工具
    代码转换工具
    
    <