Reputation: 151
I am looking to use regular expressions to organize my log files. So far I have the timestamp as group 1, JUNK IN THE MIDDLE, and the log as group 2.
I am looking to separate the junk in the middle into two groups, one holds the first value and the second holds the second value IF IT IS PRESENT.
What is the methodology to accomplish this? Fairly new to regex.
Upvotes: 0
Views: 37
Reputation: 13640
You can use the following regex:
([\d]{4}-[\d]{2}-[\d]{2}\s[\d]{2}:[\d]{2}:[\d]{2}.[\d]{3}\s\S{3})\s+([^\s]+)(?:\s+)?([^\s]+)?\s+(?:LOG: )(.+)(?=\n\d{4}-\d{2}-\d{2}|$)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Upvotes: 1