PCRE to POSIX assistance

前端 未结 1 370
梦如初夏
梦如初夏 2021-01-22 20:21

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-

相关标签:
1条回答
  • 2021-01-22 20:47

    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.
    0 讨论(0)
提交回复
热议问题