Replace string with another value
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
klb
el 4 de Jul. de 2020
What would be a good way replace a full string with first 3 letters of last word. For example '13 Jon Walker' with 'WAL' .
I have about 25 such replacements an this is indeed doable line-by-line "by-hand" using replace function, but that beats the purpose of MATLAB. Plus i might have more in future. I looked up regexprep too but it doesnt quite do that. OR have I missed it ? Is there a way I could apply a 'replace full string with first 3 letters of last word ' rule?
Thank you for your time in advance.
0 comentarios
Respuesta aceptada
Walter Roberson
el 4 de Jul. de 2020
S = {'13 Jon Walker', '23 skidoo', '0 infinite way blvd'};
upper(regexprep(S, '^.*\s+(...).*', '$1'))
1 comentario
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!