-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Is your feature request related to a problem? Please describe.
For example, complex regexes get painful to maintain; for exceedingly complex ones they are write-only. Being able to use extended regexes with embedded whitespace ((?x) or perl's /x modifier) makes a huge difference, allowing each token to be on its own line, embedded comments, diffs are more granular, etc.
Describe the solution you'd like
I think all(?) this needs is some way to do multi-line values in config file statements, which as far as I can see is not currently supported.
Onigmo used by fluent-bit supports ONIG_OPTION_EXTEND, (?x), etc. A one-line Regex that uses (?x) with embedded whitespace does seem to behave correctly, it's just without being able to make the value multi-line, most of the benefit is lost.
Describe alternatives you've considered
For now, I'm going to experiment with a preprocessor to glue multiline regexes together. Squashing newlines to spaces should work fine based on my limited (?x) tests so far.
But it would be great if the config parser could handle this natively.
Maybe some generic support for \ at end-of-line being a line-wrap indicator?
Maybe an Include directive that is valid in the value portion of a key value pair, and reads the whole thing in as the value?
Maybe special key names that indicate a multline value, where say, each line indented as much or more than the beginning of the key-name's first value is considered part of the same value? (This feels both the most special-case and the most prone to surprising failures.)
(As far as I know none of those are currently supported, I'd love to be wrong.)