Skip to content

nsq_to_file: update to use a PCRE-style regex to support including lookaheads and backreferences in a topic-pattern to allow for wildcard archiving with exclusions#1519

Open
danbf wants to merge 2 commits into
nsqio:masterfrom
danbf:add-pcre-support-for-nsq_to_file-regexs

Conversation

@danbf

@danbf danbf commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

addresses issue: #1517

Right now nsq_to_file only supports RE2 style regex's in

match, err := regexp.MatchString(t.opts.TopicPattern, topic)
through the use of the built-in golang regexp.MatchString. This prevents the use of wildcard archiving with exclusions which is a use case we have.

So a topic pattern like .* works but one like ^(?!not_so_important_events$)[a-z0-9_]+$ which would ignore the topic not_so_important_events doesn't work since it requires lookaheads which RE2 does not permit.
like: https://regex101.com/r/4S2pGx/1

Added the https://github.com/philipprochazka/regexp2 library and used it for this regex in

match, err := regexp.MatchString(t.opts.TopicPattern, topic)

@danbf danbf force-pushed the add-pcre-support-for-nsq_to_file-regexs branch from 03673ea to b694bf4 Compare January 14, 2026 21:49
…okaheads and backreferences in in topic-pattern to allow for wildcard archiving with exclusions
@danbf danbf force-pushed the add-pcre-support-for-nsq_to_file-regexs branch from 1a1451b to 30d249c Compare January 14, 2026 21:53
@danbf danbf changed the title nsq_to_file: update to use a PCRE-style regex to support including lookaheads and backreferences in in topic-pattern to allow for wildcard archiving with exclusions nsq_to_file: update to use a PCRE-style regex to support including lookaheads and backreferences in a topic-pattern to allow for wildcard archiving with exclusions Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant