Filterx regexp_subst supports match groups #394
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enhanced regexp_subst to support match group identifiers in patterns.
Since this feature could have a significant impact on performance, it is
controlled by a flag called 'groups', which is set to false by default.
To enable this feature, add the optional groups=true argument to your regexp_subst call.
example:
This feature could have been implemented using the pcre2_substitute() function provided by the PCRE2 library. However, this approach was not viable because pcre2_substitute() does not support zero-length matches, which are a critical aspect of syslog-ng's legacy regex matcher.
As a result, the implementation introduced unwanted/unnecessary code and increased complexity. Given this, I would recommend discontinuing support for zero-length matches in filterx regexps. This change would improve both performance and code maintainability. While zero-length matches may seem like a useful feature in regular expressions, their practical use cases are likely to be rare and non-critical.