0

I am trying to capture/parse event log data, windows and linux using regex in a log collection tool. I can't seem to find a regex that tells me how to capture only data between the nth space and stop matching after the following nth space.

For example:

<11>Mar 7 09:55:54 blahblah blahblahblah textiwant blahblahblahblah

How do I capture only textiwant? I realize I can get to textiwant by (\S+ \S+ \S+ \S+ \S+) but I am baffled as to how to keep only textiwant, nothing before and nothing after.

Thank you!

4

1 回答 1

2

利用捕获组和锚点:

^(?:\S+\s+){5}(\S+)

在 regex101.com 上查看演示

于 2019-03-07T16:00:14.243 回答