0001 function newString = charCutLeadingTrailing(string, theChar);
0002
0003
0004
0005
0006
0007 if nargin<1, selfdemo; return; end
0008 if nargin<2, theChar=' '; end
0009
0010 newString=string;
0011 while newString(1)==theChar
0012 newString(1)=[];
0013 end
0014 while newString(end)==theChar
0015 newString(end)=[];
0016 end
0017
0018
0019 function selfdemo
0020 string='...And the time comes....';
0021 theChar='.';
0022 output=feval(mfilename, string, theChar);
0023 fprintf('input=%s\n', string);
0024 fprintf('theChar=%s\n', theChar);
0025 fprintf('output=%s\n', output);