On Fri, May 07, 2021 at 09:07:08AM -0700, Loren Wilton wrote: > > > > header __SUB_CAP Subject:Capture /Your (\w+) Order/i $(__COMPANY)=\1 > > > > > > Would :capture play well with (e.g.) :addr, :name, :raw, etc? > > > > It might as well be a tflag or something. Why limit capturing to headers > > only? > > I hadn't intended it to be limited to headers only, but I guess the syntax > woudl have to be a little different for raw, body, full, etc, since they > don't have a part keyword in the rule syntax.
Perl already has named capture groups as legit syntax, so it would be most simple to actually use them. https://perldoc.perl.org/perlre#(?%3CNAME%3Epattern) header FROM_NAME /^From: "(?<NAME>\w+)/ ... just save the matches it in the rule code $pms->{captured_values}->{FROM_NAME}->{NAME} = $+{NAME}; Then use it in a rule: body MATCHER /My name is ${FROM_NAME:NAME}/ Don't nitpick on ${}, could be any similar syntax. Code adds this rule to FROM_NAME dependency chain. When FROM_NAME hits, run MATCHER regex (obviously first recompile the regexp).
