UltraEdit 等文本编辑器不支持在替换操作期间评估公式。这需要一个脚本和一个像 Perl 或 JavaScript 这样的脚本解释器。
UltraEdit 具有内置的 JavaScript 解释器。因此,此任务也可以通过 UltraEdit 使用 UltraEdit 脚本完成,例如下面的脚本。
if (UltraEdit.document.length > 0) // Is any file opened?
{
// Define environment for this script.
UltraEdit.insertMode();
UltraEdit.columnModeOff();
// Move caret to top of the active file.
UltraEdit.activeDocument.top();
// Defined all Perl regular expression Find parameters.
UltraEdit.perlReOn();
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=true;
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.regExp=true;
UltraEdit.activeDocument.findReplace.searchDown=true;
if (typeof(UltraEdit.activeDocument.findReplace.searchInColumn) == "boolean")
{
UltraEdit.activeDocument.findReplace.searchInColumn=false;
}
// Search for each number after case-sensitive word DATA using
// a look-behind to get just the number selected by the find.
// Each backslash in search string for Perl regular expression
// engine of UltraEdit must be escaped with one more backslash as
// the backslash is also the escape character in JavaScript strings.
while(UltraEdit.activeDocument.findReplace.find("(?<=\\bDATA)\\d+"))
{
// Convert found and selected string to an integer using decimal
// system, increment the number by eight, convert the incremented
// number back to a string using again decimal system and write the
// increased number string to file overwriting the selected number.
var nNumber = parseInt(UltraEdit.activeDocument.selection,10) + 8;
UltraEdit.activeDocument.write(nNumber.toString(10));
}
}