Problem 2602. Did you say please? - Find one string within another without strfind or regexp/regexpi
For a given string sentence, determine if the string word 'please' is present or not. If so, return the string 'OK', else return '...'. The function should not be case sensitive. Please do not use the strfind or regexp/regexpi functions in your solution.
Example:
reply = please('Help me with my homework!') reply = '...'
reply = please('Please help me with my homework') reply = 'OK'
Solution Stats
Problem Comments
-
3 Comments
See the test suite of http://www.mathworks.co.uk/matlabcentral/cody/problems/2513 for an example of how to make sure regexp and other functions are not used.
Thanks for the tip, modified the test suite and updated the problem description to include regexpi in the list of illegal functions.
Modified the test suite again, sorry if it affects your solution.
Solution Comments
Show commentsProblem Recent Solvers52
Suggested Problems
-
Project Euler: Problem 8, Find largest product in a large string of numbers
1035 Solvers
-
Project Euler: Problem 10, Sum of Primes
1639 Solvers
-
Return unique values without sorting
896 Solvers
-
274 Solvers
-
Flip the vector from right to left
8398 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!