UltraEdit脚本小例


RegExp.prototype.toUEregexp = function() { return this.toString().replace(/^//|//$/g, ""); };

UltraEdit.perlReOn();

UltraEdit.activeDocument.findReplace.regExp	= true;	



//UltraEdit.activeDocument.findReplace.replaceAll	= true;



//查找什么

//var regexpFind = /^([^/t]+)/t([^/t]+)/t/1([^/n]+)/;

//换成什么

//var replacement = "$1/t$2/t$3";



var regexpFind = /(/t[^/t]+)省([^/t]+/t[0-9]+)/;

var replacement = "$1$2";

ue_currdoc_replace(regexpFind,replacement);







//供UE使用的当前文档替换

function ue_currdoc_replace(regexpFind,replacement)

{



	//转到第一行

	UltraEdit.activeDocument.top();

	

//循环读取当前文档

	while ( UltraEdit.activeDocument.findReplace.find(regexpFind.toUEregexp()) )

	 {

	   // get line

	   var line = UltraEdit.activeDocument.selection;

	

		//var result_array = regexpFind.exec(line);

		//var [, wLineStart,wNumber] = regexpFind.exec(line);

	

	   // Write result back on top of the selected line:

	   UltraEdit.activeDocument.write(line.replace(regexpFind,replacement));

	//  UltraEdit.activeDocument.write(aaa+"/t"+bbb+"/t"+ccc); 

	}

}

你可能感兴趣的:(function,脚本,文档)