Variable creation (using a map)

This is how to create a Variable that matches a sender emails address to an item inside a Map so it can return it's value.

If you are not familiar with variable creation please read Variable creation first. Also we suggest you to read this pattern testing article and our regular expresions article.

 

Map

This is the map that we will use to test this variable examples.varMap_map.png
This map is based on a domain-corporation relation.

 

Case 1

We will search in the Sender matches for .*@corp.mxhero.com (This regEx will match any string that finish with @mxhero.com) then it will check if the map selected (Corp) has a key named corp.mxhero.com, if it does it will convert it to the value of that key, in this case 'mxHero'

varMap_simple_patt.png

Testing Case 1 conditions

To test this case we'll set a single value metakey for testing purposes.

 

varMap_simple_test_matchers.png

Click on test button

varMap_simple_results.png

The test result is divided in three parts:

  • An "easy to read" pattern
  • The result of the matched Sender converted
  • The groups found (In this case it is only one group ${0}, and it is the entire matched Sender)

 

Case 2

Now we will try to match the regEx (.*)@(mxhero.com) in the email message part Sender (this will find any string finishing with '@mxhero.com' and it will separate it in three groups delimitated with parenthesis).

Then it will search the group 2 (${2}) in the keys of the selected map (Corp) converting it to 'mxHero', that it is the value of the found key.

varMap_group_patt.png

Testing Case 2 conditions

We'll set a single value metakey for testing purposes.


varMap_test_matchers.png

Click on test button.

varMap_group_results.png

Test shows almost the same output that case 1 but it has different groups (Pattern and result):

  • group 0: Entire string found
  • group 1: (.*) any character before @
  • group 2: (mxhero.com) after @

RegEx: (.*)@(mxhero.com)

According to the aforementioned results it found the string 'mxhero.com' in {Sender} (${2}) that matches with a Key in the map Corp and it converted to 'mxHero' that is the value of the matched Key.

Have more questions? Submit a request

Comments

Powered by Zendesk