Split a string with "no delimiters"

8 ビュー (過去 30 日間)
Dwight
Dwight 2013 年 6 月 10 日
i am trying to spit a string, please help
I have a file name "yellow08car.data". I am trying to parse out the "car" from the string, but i'm unable. I have used this code to parse out the words into chunks
z = 'yellow08car.data'
[m] = regexp(z,'\w*','match')
m =
'yellow08car' 'data'
so, m{1,1} is yellow08car
I just want the "car". The length of the word after the number (car, boat, truck,vehicle) changes but the location remains the same, after a number and before a period.
so how can i parse a string within these delimiters,
Thanks for any reply

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 10 日
編集済み: Azzi Abdelmalek 2013 年 6 月 10 日
a='yellow08car'
b=regexp(a,'\d*','split')
out=b{2}
%or
a='yellow08car.data'
b=regexp(a,'[\d.]','split')
out=b{end-1}
  1 件のコメント
Dwight
Dwight 2013 年 6 月 10 日
thanks for the edit. the code works great and its very simple.
Really appreciate it!!!

サインインしてコメントする。

その他の回答 (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