help with regexp on txt file

1 回表示 (過去 30 日間)
idam hamawi
idam hamawi 2021 年 1 月 1 日
編集済み: Ive J 2021 年 1 月 2 日
Hi all,
I have a txt file which contain in one row: (example)
16/12/2020 18:30:59.443 abcabcabcabcabcabcabc Vco 7000 Ico 3200
I succeeded to capture the date and time and i need help to capture the numbers after specific name like Vgr or Igr. I want the numbers 7000 and 3200.
For the date and time i used th expresion:
expression_date = ['(?<day>\d+)/(?<months>\d+)/(?<year>\d+)'];
Date=regexp(fid{1,1},expression_date,'match');
expression_time = ['(?<hour>\d+):(?<minute>\d+):(?<second>\d+)'];
Time=regexp(fid{1,1},expression_time,'match');
Thank you!

採用された回答

Ive J
Ive J 2021 年 1 月 1 日
編集済み: Ive J 2021 年 1 月 2 日
str = '16/12/2020 18:30:59.443 Ico 3 Vco 1e7 Ico -3.2e+8 Vco 1.12e-7 Ico -3200 Vco 2.345e14';
regexp(str, '(?<=(Vco|Ico)\s*)[+-]?\d+[.]?(\d+)?[e]?[+-]?(\d+)?', 'match')
1×6 cell array
Columns 1 through 5
{'3'} {'1e7'} {'-3.2e+8'} {'1.12e-7'} {'-3200'}
Column 6
{'2.345e14'}
  5 件のコメント
idam hamawi
idam hamawi 2021 年 1 月 2 日
編集済み: idam hamawi 2021 年 1 月 2 日
Thank you, you are really helped me.
One last thing if you can.
I have a number: 1.8e-07
Do you know how can i read that?
Ive J
Ive J 2021 年 1 月 2 日
Check it now.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by