Regular Expressions 101

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
USER \((\w+)\)$
/
gm

Description

We're using the same syslog, and we want to display the date, time, and process id that's inside the square brackets. We can read each line of the syslog and pass the contents to the show_time_of_pid function. Fill in the gaps to extract the date, time, and process id from the passed line, and return this format: Jul 6 14:01:23 pid:29440.

Submitted by anonymous - 2 years ago