Cody

# Problem 2073. Split a given string from the first instance of a given character

Solution 1914389

Submitted on 28 Aug 2019
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
x='I want to split this: from this'; [y1,y2] = SplitString(x,':'); y1_correct = 'I want to split this'; y2_correct = ': from this'; assert(isequal(y1,y1_correct)) assert(isequal(y2,y2_correct))

ans = 0×0 empty cell array ans = 17

Output argument "y1" (and maybe others) not assigned during call to "SplitString". Error in Test1 (line 2) [y1,y2] = SplitString(x,':');

2   Fail
x='This one does not have the divider'; [y1,y2] = SplitString(x,':') y1_correct = 'This one does not have the divider' y2_correct = '' assert(isequal(y1,y1_correct)) assert(isequal(y2,y2_correct))

ans = 0×0 empty cell array ans = []

Output argument "y1" (and maybe others) not assigned during call to "SplitString". Error in Test2 (line 2) [y1,y2] = SplitString(x,':')

3   Fail
x='This sentence should, not have a comma.'; [y1,y2] = SplitString(x,',') y1_correct = 'This sentence should' y2_correct = ', not have a comma.' assert(isequal(y1,y1_correct)) assert(isequal(y2,y2_correct))

ans = 0×0 empty cell array ans = 15

Output argument "y1" (and maybe others) not assigned during call to "SplitString". Error in Test3 (line 2) [y1,y2] = SplitString(x,',')

4   Fail
x='Divide only @ at the @ first instance of @.'; [y1,y2] = SplitString(x,'@') y1_correct = 'Divide only ' y2_correct = '@ at the @ first instance of @.' assert(isequal(y1,y1_correct)) assert(isequal(y2,y2_correct))

ans = 0×0 empty cell array ans = 13 22 42

Output argument "y1" (and maybe others) not assigned during call to "SplitString". Error in Test4 (line 2) [y1,y2] = SplitString(x,'@')

5   Fail
x='Take that, and this, and something else.'; [y1,y2] = SplitString(x,',') y1_correct = 'Take that' y2_correct = ', and this, and something else.' assert(isequal(y1,y1_correct)) assert(isequal(y2,y2_correct))

ans = 0×0 empty cell array ans = 6 16

Output argument "y1" (and maybe others) not assigned during call to "SplitString". Error in Test5 (line 2) [y1,y2] = SplitString(x,',')