Azzera filtri
Azzera filtri

How to reverse all letters and punctuation in each individual word?

4 visualizzazioni (ultimi 30 giorni)
Just to clarify this is a HW assignment so some help (no matter how small) woudl be nice. So the assignment is to reverse an individual word in a phrase.
Example: Help me! ---> pleH !em
This is what I have so far:
clc,clear;
phrase = input('Enter any phase: ','s');
phrase = phrase(end:-1:1);
disp(phrase)
Thanks for the help everyone!

Risposta accettata

Walter Roberson
Walter Roberson il 13 Mar 2021
Hint:
phrase = 'help me!'
phrase = 'help me!'
strjoin(cellfun(@sort, regexp(phrase, ' ', 'split'), 'uniform', 0), ' ')
ans = 'ehlp !em'

Più risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by