How to use extractBetween command?
    8 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Ivan Mich
 am 28 Mai 2022
  
    
    
    
    
    Bearbeitet: per isakson
      
      
 am 29 Mai 2022
            Hello, 
I have a question about a command I want to use. First I have an input .txt value with many lines. From all the line of the input file I would like to separate the lines that between lines 
  *** SUMMARY OF DATA *** 
and 
  ***    END OF SUMMARY    ***
I am attaching the input file
I am using these commands:
yy=(regexp(fileread('input.txt'), '\r?\n', 'split')) .';
mid = extractBetween(string(yy),"*** SUMMARY OF DATA ***","***    END OF SUMMARY    ***")
but command window shows me 
345×0 empty string array
and does not  give me the lines between these phrases I would like.
Could you please help me?
0 Kommentare
Akzeptierte Antwort
  per isakson
      
      
 am 28 Mai 2022
        
      Bearbeitet: per isakson
      
      
 am 29 Mai 2022
  
      startStr and endStr must be in the same row (i.e. in a contiguous sequence of characters). 
%%
chr = fileread('input.txt');
mid = extractBetween( chr,"*** SUMMARY OF DATA ***","***    END OF SUMMARY    ***");
str = strsplit( mid{1}, '\r\n' );
str(1) = [];    % empty row because of leading \r\n
str(end) = [];  % empty row because of ending \r\n
reshape( str, [],1 )
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
				Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


