Cody

# Problem 44499. Capitilize the first letter of every word in a string

Solution 2293342

Submitted on 18 May 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
sentence = 'this is BETTER than C++'; corrected = 'This Is Better Than C++'; assert(isequal(autoCase(sentence), corrected))

j = 'this is better than c++' exp = '(^|\s).' replace = '\${upper(\$0)}' corrected = 'This Is BETTER Than C++'

Assertion failed.

2   Fail
sentence = 'hEy, tHis iS vErY wroNg!'; corrected = 'Hey, This Is Very Wrong!'; assert(isequal(autoCase(sentence), corrected))

j = 'hey, this is very wrong!' exp = '(^|\s).' replace = '\${upper(\$0)}' corrected = 'HEy, THis IS VErY WroNg!'

Assertion failed.

3   Fail
sentence = 'tHIS sENTENCE wILL bE iNVERTED'; corrected = 'This Sentence Will Be Inverted'; assert(isequal(autoCase(sentence), corrected))

j = 'this sentence will be inverted' exp = '(^|\s).' replace = '\${upper(\$0)}' corrected = 'THIS SENTENCE WILL BE INVERTED'

Assertion failed.

4   Pass
sentence = 'This Sentence Will Not Be Changed'; corrected = 'This Sentence Will Not Be Changed'; assert(isequal(autoCase(sentence), corrected))

j = 'this sentence will not be changed' exp = '(^|\s).' replace = '\${upper(\$0)}' corrected = 'This Sentence Will Not Be Changed'

5   Fail
sentence = 'HELLO THERE'; corrected = 'Hello There'; assert(isequal(autoCase(sentence), corrected))

j = 'hello there' exp = '(^|\s).' replace = '\${upper(\$0)}' corrected = 'HELLO THERE'

Assertion failed.

6   Fail
sentence = 'AlTeRnAtInG cApS'; corrected = 'Alternating Caps'; assert(isequal(autoCase(sentence), corrected))

j = 'alternating caps' exp = '(^|\s).' replace = '\${upper(\$0)}' corrected = 'AlTeRnAtInG CApS'

Assertion failed.

### Community Treasure Hunt

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

Start Hunting!