Problem 831. Find mistyped words in text (mixed-up letters)

Mistyped words are a regular occurrence in emails, texts, status updates, and the like. Many times, people send or post a second text with the correct word, usually preceded by an asterisk. In perhaps the most common case, the mistyped word contains all of the correct letters, but in the wrong order (e.g. 'I loev MATLAB').

In this problem, you are given two strings: (1) the original text and (2) the correct word(s), each preceded by an asterisk. Your function should output a cell array of the mistyped words that are being corrected.


  • Assume each mistyped word has all the correct letters, but in the wrong order
  • Assume there is only one possible option for each correct word in the second input string
  • The original text may contain punctuation, but do not include punctuation in the output
  • Corrections are case-insensitive, but the output should contain the mistyped words as written in the original text.
  • There may be more than one mistyped word; if so, the correct words are presented in order (i.e. the N-th word in the second input string corresponds to the N-th mistyped word in the original text)
  • If the second input string is empty, return an empty cell array



 str = 'Which sword are mistyped in this srting?';
 correct_words = '*words *string';


 mistyped_words = {'sword','srting'};

Solution Stats

38.1% Correct | 61.9% Incorrect
Last Solution submitted on Jun 20, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers161

Suggested Problems

More from this Author44

Problem Tags

Community Treasure Hunt

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

Start Hunting!