function [oneline] = remove_str(oneline,find_str,replace_str,matches); % Removes string FIND_STR from ONELINE, CURRENTLY CANNOT HANDLE REPLACE_STR if(nargin<4) matches = strfind(oneline,find_str); end N = length(find_str); M = length(matches); %============================================ % Thought (to get the indices right): % SIMPLE CASE, length(M)=1; % index: 123456789012345 % oneline: abcd---.---efgh % oneline: abcdefgh % matches: [5], means [5:11] or [5:5+N-1] %============================================ if ~isempty(M) for mdo=1:M match1 = matches(M-mdo+1); offending_string = match1+N-1:-1:match1; for ido = offending_string oneline(ido)=''; end end end