Hi all,
I need a script to extract the items matching a regexp entered from the keyboard into a new file with a carriage return between. I'd optionally like to pull out $1 from the match.
Any ideas? This is what I have so far:
I need a script to extract the items matching a regexp entered from the keyboard into a new file with a carriage return between. I'd optionally like to pull out $1 from the match.
Any ideas? This is what I have so far:
Code: Select all
// Is any file currently open?
UltraEdit.perlReOn();
UltraEdit.activeDocument.hexOff();
UltraEdit.activeDocument.bottom();
// Is the last line of the file terminated with a line ending?
if (UltraEdit.activeDocument.isColNumGt(1)) {
// No, insert missing line ending (DOS, UNIX or MAC).
UltraEdit.insertMode();
UltraEdit.columnModeOff();
UltraEdit.activeDocument.insertLine();
// If auto indent is enabled and last line starts with white-spaces,
// delete the automatically inserted white-spaces in the new last line.
if (UltraEdit.activeDocument.isColNumGt(1)) {
UltraEdit.activeDocument.deleteToStartOfLine();
}
}
UltraEdit.activeDocument.top();
var ActiveClipboard = UltraEdit.clipboardIdx;
UltraEdit.selectClipboard(9);
UltraEdit.clearClipboard();
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.matchCase=false;
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.regExp=true;
var bFound = false;
var myExpression= UltraEdit.getString("Please enter the expression:",1);
while (UltraEdit.activeDocument.findReplace.find(myExpression)) {
UltraEdit.activeDocument.copyAppend();
bFound = true;
}
UltraEdit.activeDocument.top();
if (bFound) {
UltraEdit.newFile();
UltraEdit.activeDocument.paste();
UltraEdit.activeDocument.top();
UltraEdit.clearClipboard();
} else UltraEdit.messageBox("There is no line starting with a period!");
UltraEdit.selectClipboard(ActiveClipboard);