Community discussions

MikroTik App
 
globalmedia
newbie
Topic Author
Posts: 30
Joined: Mon Mar 20, 2023 11:09 pm

regex on Layer7 Protocols

Sun Jun 23, 2024 4:52 am

Dear community,

I am not good with regex and I would love a help.

I would like to create a regex rule where I ignore some records:

([^\W].*[A-Za-z][-][0-9][0-9])\.ad\.example\.com

Basically I need to select any ad.example.com or *.ad.example.com EXCEPT host that start with LETTERS-\d{2}.ad.example.com.

This rule (.*[A-Za-z][-][0-9][0-9])\.ad\.example\.com can select what I would like to ignore. I have no idea about how to create a negative rule with regex.

I appreciate any help from you.
 
globalmedia
newbie
Topic Author
Posts: 30
Joined: Mon Mar 20, 2023 11:09 pm

Re: regex on Layer7 Protocols

Sun Jun 23, 2024 8:01 pm

I am using https://regex101.com/ to help me debug the expression. Finally I have done an expression that matches what I need... But when I try to insert it in the layer 7 regexp, I just got a message saying that is not possible to use it.

The expression I want to use is:

^(?![\w]*[-][\d]{2})(.*)([\.]?ad\.example\.com)$

or

^(?![\w]*[-][\d]{2})(.*[\.]?ad\.example\.com)$