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));
}
}