How to write a program, and shuffles only the inner letter of the word?

조회 수: 2 (최근 30일)
How to write a program, and shuffles only the inner letter of the word, but leave the first and last letter of the word alone? Thank you

채택된 답변

Image Analyst
Image Analyst 2017년 1월 29일
Try this:
word = 'abcdefgh'
middleIndexes = randperm(length(word)-2) + 1
newWord = [word(1), word(middleIndexes), word(end)]

추가 답변 (2개)

Stephen23
Stephen23 2017년 1월 29일
>> str = 'This is really quite easy with regular expressions.';
>> regexprep(str,'(\w)(\w+)(\w)','$1${$2(randperm(numel($2)))}$3')
ans =
Tihs is rlleay qiute esay with rlgaeur esiorsxpens.

Jan
Jan 2017년 1월 29일
편집: Jan 2017년 1월 29일
Acoicdnrg to a stduy of an Enlsigh unitsvreiy the odrer of carartehcs in a wrod deos not prevnet the riatdibaley, as lnog as the fsirt and lsat chetcraar are ccroert. The rset can be ctpemoelly mxeid and nsnneose, but it is sitll rdaleabe. Tihs wrkos, beasuce the wrdos are not raed certcaahr by ccrataher, but iifdnetied in toatl.

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by