Code covered by the BSD License  

Highlights from
String Toolkits

String Toolkits

by

 

09 Oct 2008 (Updated )

A set of useful string manipulation functions that MATLAB does not offer

strendswith(s, pat)
function b = strendswith(s, pat)
%STRENDSWITH Determines whether a string ends with a specified pattern
%
%   b = strstartswith(s, pat);
%       returns whether the string s ends with a sub-string pat.
%

%   History
%   -------
%       - Created by Dahua Lin, on Oct 9, 2008
%

%% main

sl = length(s);
pl = length(pat);

b = (sl >= pl && strcmp(s(sl-pl+1:sl), pat)) || isempty(pat);

Contact us