Home > functions > common > utility > vb_rm_trailing_slash.m

vb_rm_trailing_slash

PURPOSE ^

This function removes trailing slash(or backslash) character.

SYNOPSIS ^

function [removed] = vb_rm_trailing_slash(string)

DESCRIPTION ^

 This function removes trailing slash(or backslash) character.
 [USAGE]
    [removed] = vb_rm_trailing_slash(string);
 [IN]
     string : character string
 [OUT]
    removed : character string after removing trailing slash character.

 [HISTORY]
   2010-07-01 rhayashi initial version

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [removed] = vb_rm_trailing_slash(string)
0002 % This function removes trailing slash(or backslash) character.
0003 % [USAGE]
0004 %    [removed] = vb_rm_trailing_slash(string);
0005 % [IN]
0006 %     string : character string
0007 % [OUT]
0008 %    removed : character string after removing trailing slash character.
0009 %
0010 % [HISTORY]
0011 %   2010-07-01 rhayashi initial version
0012 %
0013 % Copyright (C) 2011, ATR All Rights Reserved.
0014 % License : New BSD License(see VBMEG_LICENSE.txt)
0015 
0016 
0017 %
0018 % --- Previous check
0019 %
0020 if ~exist('string', 'var')
0021     error('string is a required parameter.');
0022 end
0023 if ~ischar(string)
0024     error('string must be a character string');
0025 end
0026 
0027 %
0028 % --- Main Procedure
0029 %
0030 removed = string;
0031 
0032 while(1)
0033     if isempty(removed), break; end
0034 
0035     last = removed(end);
0036     switch(last)
0037         case {'\', '/', '\'}
0038             removed = removed(1:end-1);
0039         otherwise
0040             break;
0041     end
0042 end

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005