Write a function that returns a string that is a unique match (if it exists) of the string inStr from a list of strings strList.
- When there are no matches, return an empty string.
- Match is case-insensitive.
- Partial match is allowed. (anywhere in the string)
- Exact match wins over partial matches.
- When there are multiple partial matches, return an empty string.
Example 1:
>> inStr = 'ball';
>> strList = {'ball', 'bell', 'barn'};
>> outStr = findMatch(inStr, strList)
outStr =
ball
Example 2:
>> inStr = 'EMBER';
>> strList = {'May', 'June', 'July', 'August', 'September'};
>> outStr = findMatch(inStr, strList)
outStr =
September
Example 3:
>> inStr = 'Ju';
>> strList = {'May', 'June', 'July', 'August', 'September'};
>> outStr = findMatch(inStr, strList)
outStr =
''
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers270
Suggested Problems
-
378 Solvers
-
Getting the indices from a vector
11770 Solvers
-
Return a list sorted by number of consecutive occurrences
427 Solvers
-
Circular Primes (based on Project Euler, problem 35)
650 Solvers
-
Implement a bubble sort technique and output the number of swaps required
381 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Tricky one.
This problems needed more test cases. :/