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.
Notes
- 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
Example
If
str = 'Which sword are mistyped in this srting?'; correct_words = '*words *string';
then
mistyped_words = {'sword','srting'};
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers165
Suggested Problems
-
Find state names that end with the letter A
1175 Solvers
-
1270 Solvers
-
2476 Solvers
-
Number of 1s in a binary string
9083 Solvers
-
317 Solvers
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!