1

working in Graylog with regex expressions. Given this string:

FPWR2120_Access, AccessControlRuleName: Guest IPS and Malware Inspect, Prefilter Policy:

I am trying to extract "Guest IPS and Malware Inspect"

Using this expression:

^.*AccessControlRuleName:(.+)$

I get all the characters after AccessControlRuleName. How do I tell it to stop extracing once it reaches the first comma? Do I need to use a boundry or an anchor?

The fourth bird
  • 96,715
  • 14
  • 35
  • 52
William K
  • 51
  • 3

2 Answers2

1

You can use look ahead positive and look behind positive for this purpose:

(?<=AccessControlRuleName:)[\w ]*(?=,)

Link: https://regex101.com/r/FF8zCb/1

There is an explanation of this concept in this answer: https://stackoverflow.com/a/2973495/2183174

kadir
  • 488
  • 7
  • 24
1

You could use a negated character class [^,] instead matching any char except a comma.

Then match the trailing comma to make sure it is present.

^.*\bAccessControlRuleName:([^,]+),

Regex demo

The fourth bird
  • 96,715
  • 14
  • 35
  • 52