Welcome to the IDM Forum. This forum is meant as a user-to-user support mechanism where users can share knowledge and tips for all IDM software.
Since these forums are user-to-user based, IDM does not regularly read or reply to the posts in this forum. For problem reports, suggestions, or feature requests, you must email us directly. Our trained technical support staff answers most inquiries within 30 minutes.

if (UltraEdit.document.length > 0) {
var sFound = ""; // Initialize the variable for found strings.
// Define working environment. Insert/overwrite mode is not changed.
UltraEdit.columnModeOff();
UltraEdit.perlReOn();
// Ask user of script for word to find. Do not allow an empty string.
do {
var sWord = UltraEdit.getString("Word to find:",1);
}
while (!sWord.length);
// Ask user of script for number of additional words to find. Do not
// allow a negative number although in UE v18.00.0.1034 a negative
// number can't be entered by the user.
do {
var nNumber = UltraEdit.getValue("Number of additional words:",1);
} while (nNumber < 0);
// Define most of the find parameters. The search is executed from top
// of active file to end of file in a loop to find all occurrences.
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=false;
UltraEdit.activeDocument.findReplace.searchDown=true;
if (typeof(UltraEdit.activeDocument.findReplace.searchInColumn) == "boolean") {
UltraEdit.activeDocument.findReplace.searchInColumn=false;
}
UltraEdit.activeDocument.top(); // Move caret to top of active file.
if (!nNumber) {
// If the number of additional words is 0, run a simple not
// case-sensitive search for just the entered word in a loop.
UltraEdit.activeDocument.findReplace.matchWord=true;
UltraEdit.activeDocument.findReplace.regExp=false;
// If the word is found, copy it to string variable.
while (UltraEdit.activeDocument.findReplace.find(sWord)) {
sFound += UltraEdit.activeDocument.selection + "\r\n";
// It depends on your version of UltraEdit if the following lines
// are necessary or not. They are not needed in UE v18.00.0.1034.
// UltraEdit.activeDocument.endSelect();
// UltraEdit.activeDocument.key("LEFT ARROW");
// UltraEdit.activeDocument.key("RIGHT ARROW");
}
} else {
// If additional words should be also found, run a Perl regular
// expression find searching for the entered word and the additional
// words according to entered number. The regular expression to use
// is "\<WordToFind(?:\W+\w+){X}" with X being the entered number.
// \< means begin search on start of a word.
// (?: ... ) is a non marking group.
// \W+ non word character 1 or more times.
// \w+ word character (including underscore) 1 or more times.
// {X} the expression in the preceding non marking group
// matching a sequence of non word and a sequence of
// word characters exactly X times.
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.regExp=true;
var sSearch = "\\<" + sWord + "(?:\\W+\\w+){" + nNumber.toString() + "}";
while (UltraEdit.activeDocument.findReplace.find(sSearch)) {
sFound += UltraEdit.activeDocument.selection + "\r\n";
// It depends on your version of UltraEdit if the following lines
// are necessary or not. They are not needed in UE v18.00.0.1034.
// UltraEdit.activeDocument.endSelect();
// UltraEdit.activeDocument.key("LEFT ARROW");
// UltraEdit.activeDocument.key("RIGHT ARROW");
}
}
// Open a new file and write to it the found string or the error
// message. Finally move the caret in new file to top of the file.
if (!sFound.length) sFound = "Nothing found."
UltraEdit.newFile();
UltraEdit.activeDocument.write(sFound);
UltraEdit.activeDocument.top();
}
