Can a pipeline rule to match the same pattern multiple times?

I have a proxy that is inserting several cookies into each request that all match the same regex pattern and I’d like to use a pipeline rule to turn them all into fields.
There can be 1-4 of these cookies in each request.

How do I get the rule to match multiple occurrences of a pattern and put each one into a different field?

Example:
Sfje93hal=alafjawoifawfpaw849rq3948rawif0834f;

Current rule that is working to match first occurrence:
rule “extract cookies”
when
has_field(“application_name”)
then
let rawmsg = to_string($message.message);
let result = regex("(AS\w{8}=\w+;)", rawmsg);
set_field(“cookie1”, result[“0”]);
end

I did not trued, but maybe this?

rule “extract cookies”
when
has_field(“application_name”)
then
let rawmsg = to_string($message.message);
let result = regex("(AS\w{8}=\w+;)", rawmsg);
set_field(“cookie1”, result[“0”]);
set_field(“cookie2”, result[“1”]);
set_field(“cookie3”, result[“2”]);
set_field(“cookie4”, result[“3”]);
end
```

Oh… right shoulda thought of that myself.
I thought the returned array was an array of properties. Makes more sense that it’s an array of matches.

I’ll try it thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.