Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
1.99k stars 573 forks source link

New function to extract fields from strings based on regex #7587

Open jwilliams-shadowsoft opened 4 years ago

jwilliams-shadowsoft commented 4 years ago

Is your feature request related to a problem? Please describe.

A function to extract parts of a string matching a regular expression

Describe the solution you'd like

Implement a new String function to fulfill this:

a = s.extract_regex(regex, flags )

where: s is a string to parse regex is a PCRE regular expression flags is a string giving RegEx matching flags a is an array returned of values within the string that match groups in the regex

Describe alternatives you've considered

Functional code that can process specific cases can be written, but generalized regex-based extraction cannot be handled via existing functions.

Additional context

This could be used to extract fields from complex host names.

See https://community.icinga.com/t/regex-and-functions/2565

lippserd commented 4 years ago

ref/IP/19237