split a string with strsplit unique

I have this string
a='Position=a.Velocity=b.Acceleration=c.'
strsplit(a,{'Velocity=','.'})
ans =
'Position=a' 'b' 'Acceleration=c' ''
but the result I want in ans is only b how I can do it?

 Accepted Answer

Experiment with the regexp function.
Example:
a='Position=a.Velocity=b.Acceleration=c.';
Vel = regexp(a, '(?<=Velocity=)\w', 'match')
Vel =
cell
'b'

2 Comments

and in the case that you have more than one letter for example
a='Position=ah.Velocity=bl.Acceleration=ck.';
... add a ‘+’ after the ‘\w’ to match more than one letter:
a ='Position=ah.Velocity=bl.Acceleration=ck.';
Vel = regexp(a, '(?<=Velocity=)\w+', 'match')
Vel =
cell
'bl'

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!