cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2975
Views
0
Helpful
2
Replies

using regex in a dictionary command

daro
Level 1
Level 1

Hello,

we are trying to create a filter to match for Links where the address mail domain is included.

something like https://example.com/u/id?=daniel@mydomain.com

due to the amount of domains we use I would like to include the domain list with a dictionary, but it seems that the body-dictionary-match does not like regex.
I was currently testing with the follwing string (which obviously does not work), but maybe you guys can correct me there.

body-dictionary-match("(?i)http.+\\@('domain_list'))
match "http" + any character till "@" then include the names in the dictionary

I could use body-contains("(?i)http.+\\@(Test1|Test2|Test3)\\..."), but as I said we use many domains and I want it to be modular if we add a new domain.

I do not know if what I want to accomplish is even possible with that command, but maybe you guys know more.

thanks

br
Daniel

1 Accepted Solution

Accepted Solutions

Libin Varghese
Cisco Employee
Cisco Employee

Hi Daniel,

You could try using the dictionary directly in the condition such as below.

body-dictionary-match("domain_list", 1)

Then configure the dictionary with the required regex.

http.+\\@Test1

http.+\\@Test2

http.+\\@Test3

.

.

.

etc

The only other way would be to use two conditions, however this would not be accurate matching a single line.

body-contains("(?i)http.+\\@")

AND

body-dictionary-match("domain_list", 1)

Would need testing to see what works best for you.

Thank You!

Libin Varghese

View solution in original post

2 Replies 2

Libin Varghese
Cisco Employee
Cisco Employee

Hi Daniel,

You could try using the dictionary directly in the condition such as below.

body-dictionary-match("domain_list", 1)

Then configure the dictionary with the required regex.

http.+\\@Test1

http.+\\@Test2

http.+\\@Test3

.

.

.

etc

The only other way would be to use two conditions, however this would not be accurate matching a single line.

body-contains("(?i)http.+\\@")

AND

body-dictionary-match("domain_list", 1)

Would need testing to see what works best for you.

Thank You!

Libin Varghese

Hello Libin,

thanks for the update, thats exactly what i want to accomplish.
just a heads up - if you are using regex in a dictionary you do not need the double backslashes.

here is the note from the user guide describing the backslash rule:
Important Note: The backslash is also a special escape character for the parser. As a result, if you want to include backslash in your regular expression, you must use two backslashes — so that after parsing, only one “real” backslash remains, which is then passed to the regular expression system. So, if you wanted to match the example domain above, you would enter ^ik\\.ac\\.uk$.

regards
Daniel

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: