4.6

4.6 | 5 ratings Rate this file 18 downloads (last 30 days) File Size: 5.32 KB File ID: #4645

% MATLAB Comment Stripping Toolbox

by Peter J. Acklam

 

18 Mar 2004 (Updated 22 Mar 2004)

Code covered by BSD License  

A small collection of utilities for stripping MATLAB comments from strings and files.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

Download Now | Watch this File

File Information
Description

This is a small collection of utilities for stripping MATLAB comments from MATLAB code. The code may be given in strings, cell arrays of strings, or read from a file or file identifier. There is full support for stripping comments from multi-line strings, that is strings with embedded newlines, which typically appear when an entire file is read in one go.

Acknowledgements
This submission has inspired the following:
missingsemicolons
MATLAB release MATLAB 6.5 (R13)
Zip File Content  
Other Files mlstripcomments/Contents.m,
mlstripcomments/mlstripcommentsfid.m,
mlstripcomments/mlstripcommentsfile.m,
mlstripcomments/mlstripcommentsstr.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
24 Mar 2004 Brett Shoelson

Excellent! This is regular expressions on steroids...makes quick work of comment stripping. Thanks, Peter.

27 Jul 2005 Balaji Rangaswamy  
29 Mar 2006 Scott Otterson

Useful. A bit out of date, though: With R14, I'm getting a many copies of this warning:

Warning: The 'tokenize' option for regexprep is now the default behavior. If I remove 'tokenize' it goes away.

09 Oct 2009 Muhammad Arsalan

hi, very nice application. But when it works perfect up to line 277 after that it don't work as it supposed to work. There there anything that i can change?? like some memory limitations?? i need to use it on a file with 17000 lines. Any suggestions please.

12 Nov 2009 Carlos Adrian Vargas Aguilera

Great functions. Only my comments after a three points were left!

 

12 Nov 2009 Carlos Adrian Vargas Aguilera

Oh, besides of the NOT ignored lines after "...", also grouped comments are NOT ignored:
%{
bla
bla
%}
Carlos

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
strings Peter J. Acklam 22 Oct 2008 07:16:42
matlab Peter J. Acklam 22 Oct 2008 07:16:42
comments Peter J. Acklam 22 Oct 2008 07:16:42
strip Peter J. Acklam 22 Oct 2008 07:16:42
stripping Peter J. Acklam 22 Oct 2008 07:16:43
utilities Peter J. Acklam 22 Oct 2008 07:16:43
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com