필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
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!

채택된 답변

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by