Field Mask

When you create a field, Parsio will remember the "context" around it to be able to parse similar emails. By default, Parsio will only look for the context and match any found field value. However, in some cases it's useful to add an additional restriction on the value itself. That's when you can use the field mask.

Use-case

Here is a real example. A freelancer sells 2 types of digital products: Wordpress themes and Wordpress plugins on a marketplace. The marketplace forwards all transaction emails to Parsio. Because these emails are almost identical, one Parsio template will match both email types. However we want to use a separate template for each email type and add a transaction type to the exported data.

The easiest way would be to create a field "type" with an "Exact match" mask. Therefore Parsio will look for a specific keyword in the email and will apply the template only if the field with the exact value ("plugin" or "theme") will be found.

 

 

Note that a field with a non-default mask will have an orange dot on the settings icon.

Now Parsio will apply the right template to each email type.

Available masks

Field mask is template-specific e.g. different templates can apply different masks on the same field.

Parsio has a predefined set of field masks and also provides a way to create your own using regular expressions:

Mask Description

None

Match any HTML or text value

Plain text

Match text values only (no HTML tags)

Single word

Match only: letters, numbers and underscores (without spaces)

Alphanumeric string

Match only: letters and numbers

Email

A field value must be an email

Decimal

Positive or negative decimal: -12, 42, 0 etc

Exact match

Match the exact value

Custom regex

Specify your own mask using regular expressions

 

Regular expressions

Regular expressions (or "regex") are special strings representing a pattern to be matched.

Let's say we want to parse this string: Timestamp: Monday, 15 November 2021 18:14:35 into fields: date (15 November 2021) and time (18:14:35). However, if we will just create a template with these 2 fields, Parsio will incorrectly extract the values:

This happens because of the lack of context around fields. Fortunately, we can easily fix the issue by adding a custom regex on the field date[a-zA-Z0-9 ]*. Here how it works in a nutshell:

  • Square brackets defines a character class. We tell Parsio that our value can contain: any lettersnumbers and spaces.
  • The asterisk symbol (*) is called quantifier. It matches the previous token between zero and unlimited times, as many times as possible (greedy quantifier).

 

Regular expressions is a complex topic which is beyond the scope of this article but here are a couple of useful links:


Was this article helpful?
© 2024 Parsio Knowledge Base