RosettaCodeData/Task/Strip-comments-from-a-string/MATLAB/strip-comments-from-a-string.m
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

8 lines
206 B
Matlab

function line = stripcomment(line)
e = min([find(line=='#',1),find(line==';',1)]);
if ~isempty(e)
e = e-1;
while isspace(line(e)) e = e - 1; end;
line = line(1:e);
end;
end;