How to write a program, and shuffles only the inner letter of the word?
2 views (last 30 days)
Show older comments
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
Accepted Answer
Image Analyst
on 29 Jan 2017
Try this:
word = 'abcdefgh'
middleIndexes = randperm(length(word)-2) + 1
newWord = [word(1), word(middleIndexes), word(end)]
More Answers (2)
Stephen23
on 29 Jan 2017
>> 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
on 29 Jan 2017
Edited: Jan
on 29 Jan 2017
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.
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!