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?

 채택된 답변

Star Strider
Star Strider 2017년 4월 6일

0 개 추천

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

댓글 수: 2

Patrick Brown
Patrick Brown 2017년 4월 7일
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'

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

질문:

2017년 4월 6일

댓글:

2017년 4월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by