Extract Last two Words from strings in cell
Show older comments
A={'There is a world of good you could perform';
'All the money in the world couldnot have saved her';
'W';
'My world'}
Accepted Answer
More Answers (1)
>> A = {'There is a world of good you could perform'; 'All the money in the world couldnot have saved her'; 'W'; 'My world'}
A =
'There is a world of good you could perform'
'All the money in the world couldnot have saved her'
'W'
'My world'
>> C = regexp(A,'(\w+\s*){1,2}$','match','once')
C =
'could perform'
'saved her'
'W'
'My world'
Categories
Find more on Cell Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!