MATLAB: About import .txt file,how to change special character in its name

import

like Chande.2008052716-17hZCFPF.GY.txt after importing , then the variable name change to Chande_2008052716_17hZCFPF_GY, how to make it,thanks
what i need is deleting the last .txt and changing special symbols like .and – to _, just change the string

Best Answer

s='Chande.2008052716-17hZCFPF.GY.txt'
s1=strrep(s,'.','_')
s1=strrep(s1,'-','_')
%or
s='Chande.2008052716-17hZCFPF.GY.txt'
s1=regexprep(s,'[-\.]+','_')