How to apply multiple filters in asterisk 20.4.0 AMI interface

I just want to filter all event that contains "Event: Hangup and “Channel: PJSIP/ANCONA_UFFICIO” against an event like this:

Event: Hangup
Privilege: call,all
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: xxxxxxx
CallerIDName: xxxxxxx
ConnectedLineNum: 235
ConnectedLineName: WASSILIS IT
Language: it
Context: ext-group
Exten: h
Priority: 1
Uniqueid: 1700241723.5022
Linkedid: 1700241723.5022
Cause: 16
Cause-txt: Normal Clearing

So I’m using this regex:

Action: Login
Username: user
Secret: mypassword

Action: Filter
ActionID: 998
Operation: Add
Filter: [\s\S]*Event: Hangup\b[\s\S]*Channel: PJSIP\/ANCONA_UFFICIO[\s\S]*

and it doesn’t works, my ami console doesn’t show any events on any kind of hangup, the strange thing is that if I separate the two rules like this, it will work

Action: Filter
ActionID: 998
Operation: Add
Filter: [\s\S]*Event: Hangup\b[\s\S]*

Action: Filter
ActionID: 998
Operation: Add
Filter: [\s\S]*Channel: PJSIP\/ANCONA_UFFICIO[\s\S]*

but in this way is like an OR logical condition but I need and AND. I tried the above regex in regex101: build, test, and debug regex and it’s working as expected without any global flag activated. So must be sometghing in how regex works in AMI

Ok the solution is this, probably AMI regex follows an older pattern that doesn’t accept [\s\S] and with the dot is considering new lines too… anyway I tried 1milions combinations and I found the solution is this

Filter: Event: Hangup\b.*Channel: PJSIP\/ANCONA_UFFICIO

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