フィルターのクリア

Matlab using regexp function i want to parse string and data

5 ビュー (過去 30 日間)
Life is Wonderful
Life is Wonderful 2019 年 5 月 21 日
編集済み: per isakson 2019 年 5 月 25 日
Hi
I have a string :"2019-05-10T21:42:59.980043+00:00 ERR kernel: [ 82.127095] sof-audio-pci 0000:00:1f.3: error: can't find message header 0x0"
I want to parse the data Like using regexp
ERR_Kernel = [82]
sof-audio-pci = 0000:00:1f.3
error.can't find message header = 0x0
Thanks
  4 件のコメント
Walter Roberson
Walter Roberson 2019 年 5 月 22 日
Unfortunately time that includes timezone offset is not enough to specify which time zone should be used. Considering that the time zone offset is 00:00 then can we assume UTC?
Life is Wonderful
Life is Wonderful 2019 年 5 月 22 日
Hi Walter
But ignonre the TimeZone , can you please suggest using regexp function what should be the pattern I should use to parse the Data .
Data.OutPut1 = ERR kernel: [ 82.127095]
Data.OutPut2 = sof-audio-pci 0000:00:1f.3
Data.OutPut3 = error: can't find message header 0x0

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

採用された回答

Bob Thompson
Bob Thompson 2019 年 5 月 22 日
There are a few things I notice here.
1) I have edited your patterns so they should capture what you're looking for.
2) It seems like you don't have any indexing on 'tokens' in your while loop. This is not necessarily a problem except when you have more than one set of values able to be returned for a single tline. You should index the different possible token results.
3) It seems like you just want the numbers from the different lines, not the text themselves. To do this just use 'tokens' instead of 'match' in your regexp command. Also, be sure to change your tokens variable name to something else to prevent any naming errors.
4) What is the purpose of pattern3? You don't keep any of the results for later use, so why bother finding it?
pattern1 = 'ERR kernel:\s.\s*(\d+.\d+).';
pattern2 = 'sof-audio-pci (\d+.\d+.\d\w.\d)';
pattern4 = 'header (\d\w\d)';
  4 件のコメント
Bob Thompson
Bob Thompson 2019 年 5 月 24 日
I don't know how much I personally will be able to help with this matter. I would suggest posting a new question outlining your desire for help with the plotting.
Walter Roberson
Walter Roberson 2019 年 5 月 25 日
sriram shastry comments to Bob Nbob:
Thanks a lot for all the help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by