Home > vbmeg > 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 isempty(string)
0024     removed = string;
0025     return;
0026 end
0027 if ~ischar(string)
0028     error('string must be a character string');
0029 end
0030 
0031 %
0032 % --- Main Procedure
0033 %
0034 removed = string;
0035 
0036 while(1)
0037     if isempty(removed), break; end
0038 
0039     last = removed(end);
0040     switch(last)
0041         case {'\', '/', '\'}
0042             removed = removed(1:end-1);
0043         otherwise
0044             break;
0045     end
0046 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005