ffs_in = 'logfile.txt';
ffs_out = 'logout.txt';
fid_in = fopen( ffs_in, 'rt' );
fid_out = fopen( ffs_out, 'wt' );
xpr = [ '(?<host>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+-\s+' ...
'(?<username>\S+)\s+\[(?<time>[^\]]+)\]\s+"(?<request>[^"]+)"' ];
while not( feof( fid_in ) )
chr = fgetl( fid_in );
sas = regexp( chr, xpr, 'names' );
for f = reshape( fieldnames( sas ), 1,[] )
fprintf( fid_out, '%s: %s\n', f{1}, sas.(f{1}) );
end
fprintf( fid_out, '\n' );
end
fclose( fid_in );
fclose( fid_out );
6 Comments
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/632089-case-is-closed#comment_1099904
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/632089-case-is-closed#comment_1099904
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/632089-case-is-closed#comment_1099929
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/632089-case-is-closed#comment_1099929
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/632089-case-is-closed#comment_1100334
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/632089-case-is-closed#comment_1100334
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/632089-case-is-closed#comment_1100374
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/632089-case-is-closed#comment_1100374
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/632089-case-is-closed#comment_1102814
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/632089-case-is-closed#comment_1102814
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/632089-case-is-closed#comment_1105589
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/632089-case-is-closed#comment_1105589
Sign in to comment.