I need to extract the profile for these syslog entries.
May 11 09:35:59 server-0548 ea_appserver: env=ACPT profile=product_api java[31185]: 2017-05-11 09:35:59,210 server-0548 org.hibernate.internal.SessionFactoryImpl ServerService Thread Pool -- 51 HHH000008: JTASessionContext being used with JDBCTransactionFactory; auto-flush will not operate correctly with getCurrentSession()
The following regex works for PCRE but I can't seem to convert it over to POSIX.
(?m)profile=(\S+)
I've tried
[^=]*$
and
.*profile=(.*)
but can't get either to stop at just product_api
POSIX ERE does not support inline regex modifiers, and shorthand character classes are not always supported. Note that even in your (?m)profile=(\S+)
PCRE regex, the (?m)
MULTILINE modifier is redudant as there is no ^
, nor $
to redfine the behavior of. What you may use is a POSIX character class [:space:]
(matching any whitespace) inside a negated bracket expression:
profile=([^[:space:]]+)
Details:
profile=
- a literal substring([^[:space:]]+)
- Group 1: one or more characters other than those that can be matched with [:space:]
POSIX character class.