MATLAB: How to ignore punctuation in a user string while scanning for words (textscan())

malayregexptextscan

It works perfectly now. thanks to oleg and lucas for ur help! if ur interested, here's how it looks like in the end:
function pushbutton1_Callback(hObject, eventdata, handles)
words = get(handles.editbox, 'string'); %scans user input string from editbox
wavdirectory = 'C:\Program Files\MATLAB\R2010b\Recordings\';
wordsstring = regexp(words, '\w+', 'match') ; %reads string only, ignores punctuation
[j, k] = size(wordsstring); %stores number of words in user input string
for m = 1:k
thisfid = [wavdirectory wordsstring{m} '.wav'];
try
[y, fs] = wavread(thisfid);
sound(y, fs);
catch
fprintf(1,'Failed to process file wave "%s" because: ', thisfid);
lasterror
end
end

Best Answer

This removes the specified punctuation in your word:
regexprep(word, '[-!,.?]', '')