- AuthorPosts
- May 11, 2012 at 8:39 am #10345userParticipant
hello!
I need a macro that will delete all lines that match any of the regexes that are in a txt file (one below the other)
is this possible?
thanks!
May 14, 2012 at 9:43 am #10352userParticipantI think I need to make it more clear:
I am looking for a more convenient way than maintaining a list of:
document.selection.Replace(“^455.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
I just want to have a list of the regex only and then the command to be the same
thanks
May 15, 2012 at 8:43 am #10354userParticipantinstead of doing the below, is there a way to set a var with the numbers and use a single line?
document.selection.Replace(“^918.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^919.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^920.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^921.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^922.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^924.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^925.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^926.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^927.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^928.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^929.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^946.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^972.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1093.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1109.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1166.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1185.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1188.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1189.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1190.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1191.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1192.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1193.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1194.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1196.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1198.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1200.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1223.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1436.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1438.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1439.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1440.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1441.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1442.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1443.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1444.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1466.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1469.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1636.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1637.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1638.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1640.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1641.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1648.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1650.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1862.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1871.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1872.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1874.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1875.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1883.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);
document.selection.Replace(“^1884.*$”, “”, eeFindNext | eeFindSaveHistory | eeFindReplaceRegExp | eeReplaceAll);thanks
May 15, 2012 at 5:16 pm #10357StefanParticipantIf it allowed to match ANY number between ‘918’ and ‘1884’ ?
Then try:
for ( Numb = 918; Numb <= 1884; Numb++){
document.selection.Replace("^" + Numb + ".*$", "", eeFindNext
| eeFindReplaceRegExp | eeReplaceAll);
}
Or the showed numbers only?
.
May 16, 2012 at 8:15 am #10358userParticipantthe shown numbers only
also, in a way that the numbers list will be easily maintained, ie. add and remove entries
that’s the difficult part :/May 16, 2012 at 11:49 am #10361StefanParticipantHaving e.g. “c:tempnumbers.txt” with one number at each line.
c:tempnumbers.txt:
123
222
345Use an code like this to read this file into an array.
Then use a FOR loop to process each array indices (0 till highest index)
and inside the FOR loop use the current index to do what you want.
// 1.) helper code to read an files content
//Your file with the numbers, each at an own line:
NumbFile = "c:tempnumbers.txt";
//============================================
fso = new ActiveXObject("Scripting.FileSystemObject");
oFile = fso.OpenTextFile(NumbFile, 1, false, 0);
content = oFile.ReadAll();
oFile.Close();
fso = null;
//alert(content);
//============================================
// 2.) the needed code itself
//For Each Line In Lines Do:
LinesArray = content.split("n");
for (LineNumb = 0; LineNumb < LinesArray.length; LineNumb++){
//do here what you want...
bAnswer = confirm( LinesArray[LineNumb] );
if (bAnswer == false){break;}
}
For more about Javascript FileSystemObject and text files read e.g.:
http://www.ezineasp.net/post/Javascript-FSO-OpenTextFile-Method.aspxMay 16, 2012 at 1:41 pm #10363userParticipantgreat! thanks!
- AuthorPosts
- You must be logged in to reply to this topic.