Cody

# Problem 541. Use of regexp

Solution 1871922

Submitted on 11 Jul 2019 by Michael Cappello
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   Pass
x = 'I played piano. John played football. Anita went home. Are you safe?'; y = {'I played piano.' 'Anita went home.' 'Are you safe?'}; assert(isequal(lazy(x),y))

y = 1×4 cell array {'I played piano.'} {'John played football.'} {'Anita went home.'} {'Are you safe?'} y = 1×4 cell array {'I played piano.'} {0×0 char} {'Anita went home.'} {'Are you safe?'} y = 1×3 cell array {'I played piano.'} {'Anita went home.'} {'Are you safe?'}

2   Pass
x = 'Are you okay? Who are you? Olga will call you. Sam saw me.'; y = {'Olga will call you.'}; assert(isequal(lazy(x),y))

y = 1×4 cell array {'Are you okay?'} {'Who are you?'} {'Olga will call you.'} {'Sam saw me.'} y = 1×4 cell array {0×0 char} {0×0 char} {'Olga will call you.'} {0×0 char} y = 1×1 cell array {'Olga will call you.'}

3   Pass
x = 'One is more. Than what? No it''s not. But why? Angela said so.'; y = {'One is more.' 'Angela said so.'}; assert(isequal(lazy(x),y))

y = 1×5 cell array {'One is more.'} {'Than what?'} {'No it's not.'} {'But why?'} {'Angela said so.'} y = 1×5 cell array {'One is more.'} {0×0 char} {0×0 char} {0×0 char} {'Angela said so.'} y = 1×2 cell array {'One is more.'} {'Angela said so.'}

4   Pass
x = 'One plus two. Is four. No, that''t not right. It''s three.'; y = {'One plus two.' 'It''s three.'}; assert(isequal(lazy(x),y))

y = 1×4 cell array {'One plus two.'} {'Is four.'} {'No, that't not right.'} {'It's three.'} y = 1×4 cell array {'One plus two.'} {0×0 char} {0×0 char} {'It's three.'} y = 1×2 cell array {'One plus two.'} {'It's three.'}

5   Pass
x = 'I went home. After the game. It was sad. It was lame. It was great!'; y = {'I went home.' 'After the game.' 'It was lame.'}; assert(isequal(lazy(x),y))

y = 1×5 cell array {'I went home.'} {'After the game.'} {'It was sad.'} {'It was lame.'} {'It was great!'} y = 1×5 cell array {'I went home.'} {'After the game.'} {0×0 char} {'It was lame.'} {0×0 char} y = 1×3 cell array {'I went home.'} {'After the game.'} {'It was lame.'}

6   Pass
x = 'One, two, three. Climb the tree. Four, five, six. It''s not here. Eight and nine. That''s fine.'; y = {'One, two, three.' 'It''s not here.' 'Eight and nine.'}; assert(isequal(lazy(x),y))

y = 1×6 cell array {'One, two, three.'} {'Climb the tree.'} {'Four, five, six.'} {'It's not here.'} {'Eight and nine.'} {'That's fine.'} y = 1×6 cell array {'One, two, three.'} {0×0 char} {0×0 char} {'It's not here.'} {'Eight and nine.'} {0×0 char} y = 1×3 cell array {'One, two, three.'} {'It's not here.'} {'Eight and nine.'}

7   Pass
x = 'Either one is fine. Why? Because he said so.'; y = {'Either one is fine.'}; assert(isequal(lazy(x),y))

y = 1×3 cell array {'Either one is fine.'} {'Why?'} {'Because he said so.'} y = 1×3 cell array {'Either one is fine.'} {0×0 char} {0×0 char} y = 1×1 cell array {'Either one is fine.'}

### Community Treasure Hunt

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

Start Hunting!