MATLAB: Cut and re-join strings

strings

Hello, I am trying to create a function that will cut a section out of a string and join the two remaining parts togather.
I am getting some weird results towards the end
here is my code
pat = 'MATLAB';
cliplength = length(pat);
stringinput = 'D:\Documents and Settings\212068586\My Documents\MATLAB\help'
endpoint = regexp(stringinput, pat);
newstringstart = [];
newstringtail = [];
for w = 1:length(stringinput)
if w < endpoint
newstringstart(w) = stringinput(w);
end
end
if (((endpoint + cliplength) < w) && (w > endpoint))
for h = (endpoint + cliplength):length(stringinput)
newstringtail(h) = stringinput(w);
end
%newstring(w) = stringinput(w - (endpoint + cliplength));
end
disp(char(strcat(newstringstart, newstringtail)))
Any ideas why it isn't working?
Thanks
Bill

Best Answer

Rather than using a verbal description, show us what you want. For example, if you start with these:
pat = 'MATLAB';
stringinput = 'D:\Documents and Settings\212068586\My Documents\MATLAB\help'
what do you want to have at the end?