Matching Rules
How to create your own Matching Rules
- Create an assignment strategy. The assignment strategy defines the rules for extracting important information from a payment description.
- Define an ident to attach the strategy to a merchant payment account later.
- Select a target type to define which kind of entity we try to match the payment with.
- Note: If you select Order and the Order has already been billed, we will still assign it to the invoice.
- Define the regex to parse the payment description and extract the assignment relevant data (most often the document ident).
- The Target Ident Pattern can be used to overwrite a found regex with a different value. It can for example be used to switch out special characters found in payment strings with the special characters used in your document idents.
- Enabling the slider "Disable Multiple Regex Matches" means that if a regex is used on a payment description and more than one match occurs, then the attempt on automatic assignment fails and a manual assignment has to be made.
- Configure which matching rules should be used for each merchant payment account.
- Define which merchant payment account you want to add matching rules to.
- Add the matching rules.
- Note: The order indicates in which orders we will attempt to find matches. If a match has been found the later regex rules won't be considered.
Regular Expressions Guide
Regular Expressions (Regex) are powerful tools used for matching patterns in text, which the Nitrobox utilizes
to provide exemplary customizability for your needs.
This guide provides an introduction to regex, with examples to help you create your own regex rules. For testing and refining your regex patterns, we recommend using Regex101.
Basics of Regex
A regex is a sequence of characters that defines a search pattern. Here are some basic components and concepts:
- Literal Characters: Match the exact characters. For example,
abc
matches "abc". - Metacharacters: Special characters that have specific meanings:
.
: Matches any single character except newline.^
: Matches the start of a string.$
: Matches the end of a string.*
: Matches 0 or more occurrences of the preceding element.+
: Matches 1 or more occurrences of the preceding element.?
: Matches 0 or 1 occurrence of the preceding element.\
: Escapes a metacharacter, treating it as a literal character.
Common Patterns
-
Matching Digits:
\d
- Example:
\d{3}
matches any three digits (e.g., "123").
- Example:
-
Matching Words:
\w
- Example:
\w+
matches one or more word characters (e.g., "hello").
- Example:
-
Whitespace:
\s
- Example:
\s+
matches one or more whitespace characters (e.g., spaces, tabs).
- Example:
-
Character Sets:
[abc]
- Example:
[aeiou]
matches any one vowel.
- Example:
-
Ranges:
[a-z]
- Example:
[0-9]
matches any digit from 0 to 9.
- Example:
Examples
Pattern: [a-zA-Z0-9_-]{8,20}
[a-zA-Z0-9_-]{8,20}
- Description: Matches any combination of letters (uppercase and lowercase), digits, underscores, and hyphens.
- Length: Between 8 and 20 characters.
Pattern: ^(ident-)([1-9]|[1-9][0-9]|100)$
^(ident-)([1-9]|[1-9][0-9]|100)$
- Description: Validates an identifier with a specific range.
- Details:
- Starts with
ident-
- Followed by a number between 1 and 100, inclusive.
- The number can be a single digit (1-9), a two-digit number (10-99), or exactly 100.
- Starts with
Testing Your Regex
We recommend using Regex101 to test your regex patterns. This tool provides feedback and detailed explanations of your regex components.
To use Regex101:
- Visit Regex101.
- Enter your regex pattern in the "Regular Expression" field.
- Input the text you want to test in the "Test String" field.
- View matches, explanations, and any errors in real-time.
By following this guide, you can become proficient in creating and using regex patterns for your configurations. Happy matching!
Updated 2 months ago