I'm working with JavaScript and I need to parse a log file in order to extract a substring.
This is an example fo my log file:
Feb 04 11:20:48 info: VPN disconnected: admin @ 6051:abcdefgh [NB017] (duration: 00:05:32)
Feb 04 12:59:21 info: VPN connected: admin @ 6051:abcdefgh [NB017]
Feb 04 12:59:21 info: Connected to 123.123.123.123 (TLS)
Feb 04 12:59:21 info: Data tunnel connected:
Feb 04 12:59:21 info: Data tunnel operational!
Feb 04 12:59:53 info: VPN disconnected: admin @ 6051:abcdefgh [NB017] (duration: 00:00:32)
Feb 04 13:01:03 info: VPN connected: admin @ 6051:abcdefgh [NB017]
Feb 04 13:01:03 info: Connected to 123.123.123.123 (TLS)
Feb 04 13:01:03 info: Data tunnel connected:
Feb 04 13:01:03 info: Data tunnel operational!
Feb 04 13:01:35 info: VPN disconnected: admin @ 6051:abcdefgh [NB017] (duration: 00:00:40)
Feb 04 13:49:26 info: VPN connected: admin @ 6051:abcdefgh [NB017]
Feb 04 13:49:27 info: VPN disconnected: admin @ 6051:abcdefgh [NB017] (duration: 00:00:09)
Feb 04 13:50:06 info: VPN connected: admin @ 6051:abcdefgh [NB017]
Feb 04 13:50:06 info: Connected to 123.123.123.123 (TLS)
Feb 04 13:50:06 info: Data tunnel connected:
Feb 04 13:50:07 info: Data tunnel operational!
Feb 04 15:37:57 info: (Log Displayed)
I need to extract the user who make the last connection since there are multiple connection in the log.
For instance starting from "VPN connected: " to the last "]".
I tried with this RegEx
VPN connected([^.]+)]
but JS returns several log when I need only the last one.
How can I improve mi RegEx?