UltraEdit scripting using JavaScript and wildcards -
i have program using combination of javascript , ultraedit scripting. program has array of strings search in file/tab. if found, moves corresponding lines new file/tab. when using exact match works great.
however, source values not exact matches. values in file ######-## values after dash vary. have value dash. attempted build wildcard array values, , i've attempted concatenate .find function no success. thoughts appreciated.
here code i'm executing script within ultraedit. i've truncated array 50 values contained purpose of demonstration.
// start @ beginning of file ultraedit.activedocument.top(); // search string variable used copying of lines //dd011881 - building array of values var delstring = new array() delstring[0] = "'99999999'"; delstring[1] = "'169-*'"; delstring[2] = "'5482-*'"; delstring[3] = "'5998-*'"; delstring[4] = "'36226-*'"; delstring[5] = "'215021-*'"; // array loop value var x = 0; var arraylen = delstring.length // start nothing on clipboard ultraedit.clearclipboard(); (x=0; x<arraylen; x++) { // establish our search string loop condition var bfound = false; while (ultraedit.activedocument.findreplace.find(delstring[x])){ ultraedit.activedocument.selectline(); ultraedit.activedocument.copyappend("^c" + "\n"); bfound = true; } ultraedit.activedocument.top(); if (bfound) { ultraedit.document[6].paste(); ultraedit.activedocument.top(); ultraedit.clearclipboard(); } } // loop
in ultraedit script want run ultraedit regular expression find in while loop, have never set regular expression engine nor find parameter. script executing find internal defaults finds (case-insensitive, non-regular expression search downwards, not matching whole words perl regular expression engine selected).
insert in ultraedit script below command ultraedit.clearclipboard();
following lines:
ultraedit.uereon(); 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; }
now ultraedit regular expression selected script , find parameters set running case-sensitive (faster) regular expression search.
and please remove "^c" + "\n"
command ultraedit.activedocument.copyappend()
command not take parameter. command above, entire line including line termination selected , selection appended clipboard, not string put parentheses of command copyappend()
.
Comments
Post a Comment