EmEditor (text editor) Forum Index
   Questions and Answers about Macros
     delete all lines that match any of the regexes that are in a txt file
Register To Post

Flat Previous Topic | Next Topic
Poster Thread
Stefan
Posted on: 5/16/2012 3:49 am
Home away from home
Joined: 7/14/2008
From: Germany, EU
Posts: 264
Re: delete all lines that match any of the regexes that are in a txt file

Having e.g. "c:\temp\numbers.txt" with one number at each line.

c:\temp\numbers.txt:
Quote:
123
222
345




Use 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:\\temp\\numbers.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.aspx
Flat Previous Topic | Next Topic


Subject Poster Date
   delete all lines that match any of the regexes that are in a txt file user 5/11/2012 12:39 am
     Re: delete all lines that match any of the regexes that are in a txt file user 5/14/2012 1:43 am
       Re: delete all lines that match any of the regexes that are in a txt file user 5/15/2012 12:43 am
         Re: delete all lines that match any of the regexes that are in a txt file Stefan 5/15/2012 9:16 am
           Re: delete all lines that match any of the regexes that are in a txt file user 5/16/2012 12:15 am
           » Re: delete all lines that match any of the regexes that are in a txt file Stefan 5/16/2012 3:49 am
               Re: delete all lines that match any of the regexes that are in a txt file user 5/16/2012 5:41 am

Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文