フィルターのクリア

split a string with strsplit unique

2 ビュー (過去 30 日間)
Patrick Brown
Patrick Brown 2017 年 4 月 6 日
コメント済み: Star Strider 2017 年 4 月 7 日
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 日
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.';
Star Strider
Star Strider 2017 年 4 月 7 日
... 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 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by