removing suffiex or prefix from sting
Mostrar comentarios más antiguos
Hi there
i want code which delete the suffix or prefix in string please?
Respuesta aceptada
Más respuestas (2)
Elias Gule
el 4 de Oct. de 2016
try this:
str = 'unbecomingly';
prefix = 'un'; % The prefix to remove
suffix = 'ly'; % The suffix to remove
regex = {['^' prefix],[suffix '$']}; % the regular expressions for prefix & suffix
replacements = {'',''}; % Replacement strings
newstr = regexprep(str,regex,replacements); % The new string with suffix or prefix or both replaced by corresponding replacement string.
Ebtesam Almansor
el 6 de Oct. de 2016
0 votos
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!