Problem 2440. Text processing - Help Johnny write a letter home from camp
Johnny overuses the word 'great'. Write a script that will help him with this and future letters. If a sentence contains more than one occurrence of 'great', replace the second occurrence with 'awesome'.
textIn = strcat('I am having a great time at summer camp. The camp', ...
' counselors are great and the activities are great. Monday', ...
' we went kayaking and Tuesday we learned archery. Archery was', ...
' great and I hit the bull''s eye which everyone was said was', ...
' really great. -Love Johnny');
Solution Stats
Problem Comments
-
3 Comments
Jan Orwat
on 16 Jul 2014
Hey Dave! It would be awesome, if there was sentences with more than 2 'great' or words like 'greater'.
J.R.! Menzinger
on 21 Jul 2014
Definitively I must learn MORE regexp... :-/ I knew what to do, but I couldn't implement it.
Dyuman Joshi
on 21 Oct 2022
A test case has been added as per Jan Orwat's suggestion.
Solution Comments
Show commentsProblem Recent Solvers71
Suggested Problems
-
2926 Solvers
-
Read a column of numbers and interpolate missing data
2284 Solvers
-
Sum all integers from 1 to 2^n
15320 Solvers
-
422 Solvers
-
Let's get back to school, and create multiplication tables
213 Solvers
More from this Author3
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!