问题
When looking for some logs in one file I got two types of logs (one with white spaces and one without). I would now like to extract doSomething and doAnotherThing out of these logs with one regular expression.
Logfile 1: "taskType":"doSomething"
Logfile 2: "taskType" : "doAnotherThing"
I coded this regular expression: taskType.....(?<taskType1>\w+)
It works good for Logfile 1 but not for Logfile 2, because it cuts the first two characters of the word. Is there a way to eliminate this issue?
Thanks!
回答1:
"taskType"\s?:\s?"(doSomething|doAnotherThing)"
works for me, try it here https://regex101.com/r/Mx1RtT/1
来源:https://stackoverflow.com/questions/64912713/how-to-modify-regular-expressions-so-that-it-extracts-same-fields-of-both-fields