Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can regexp support multiline ? #40

Open
Quenii opened this issue Apr 25, 2024 · 5 comments
Open

can regexp support multiline ? #40

Quenii opened this issue Apr 25, 2024 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@Quenii
Copy link

Quenii commented Apr 25, 2024

I tried something like: \d+-\d+\n\w+
\n doesn't work

@hamster620
Copy link
Collaborator

@Quenii You can refer to #31 for defining log patterns for multiple lines. Or you can provide a sample log file you want to parse so that we can check the question. Thanks.

@Quenii
Copy link
Author

Quenii commented Apr 28, 2024

i've tried #31, but haven't figured out the logic

(?<TimeSpan>\d+)\-(?<Extra1>\d+)\-(?<Extra2>\d+)\-(?<Extra3>\d+)\-\d+\-\d+\-\d+\-\d+\-\d+\-\d+\-\d+\-\d+ : Modeno:(?<Extra4>.*)
to match
4377-3-15092-291-34-1-1440-1449-107-0-0-254 : Modeno:HQ SSD 4000GB

(?<TimeSpan>\d+)\-(?<Extra1>\d+)\-(?<Extra2>\d+)\-(?<Extra3>\d+)\-\d+\-\d+\-\d+\-\d+\-\d+\-\d+\-\d+\-\d+ : UNC. lba:(?<Extra5>\w+) paa:0x(?<Extra6>\w+).*d:(?<Extra7>\d+).*
to match
123392-234-15057-291-34-2-5605376-6523805-176-0-0-254 : UNC. lba:9801C0 paa:0xFF2A98 b:136 p:811 d:7 uncM:0-20000000_FFFF,..

while I've tons of lines to match, can't figure out which is repeatable or skippable
pasted some clip of my log

Untitled-1.txt

@hamster620
Copy link
Collaborator

@Quenii According to the log file you provided, I assume that every log starts with \d+(\-\d+)+ and all following lines which NOT start with \d+(\-\d+)+ should be treat as multi-line message. Then we can define 2 log patterns to parse logs:

  1. (?<Extra1>\d+(\-\d+)+)\s*:\s*(?<Message>.*) which defines the start of log.
  2. ^(?!\d+(\-\d+)+)(?<Message>.*) defines message to concatenate after. The pattern is repeatable because it can be presented more than 1 times, and skippable because the line may not always be presented.

You can import and refer to the log profile: GitHub#41.json

@hamster620 hamster620 added the question Further information is requested label Apr 28, 2024
@hamster620 hamster620 self-assigned this Apr 28, 2024
@Quenii
Copy link
Author

Quenii commented Apr 28, 2024

thanks a lot
the json you provided works
but what I want is to parse more data from message field
ie, several Extra I posted above

@hamster620
Copy link
Collaborator

thanks a lot the json you provided works but what I want is to parse more data from message field ie, several Extra I posted above

@Quenii What output you want to see in the log viewer based-on the log you provided?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants