Applies to: SureFile Enterprise DMS Administrator
SureFile Enterprise matches emails to rules to determine where to store them. Each rule includes one or more conditions that define how to match emails, using either keywords or regular expressions (regex). Regular expressions are tricky, so we've included a regex builder in the SureFile administration portal to help you define regex for named groups and conditions.
Getting started
You can access the regex builder in the SureFile admin portal anywhere you see a button. For example, when defining a condition for a SureFile rule.
When you click , the Regex Segments flyout appears.
- Regex segment
- (regex segment) button
- Resulting Regex field
- Testing field
- Ok button
- Cancel button
Build a regular expression
Regex segments are the building blocks used to construct a regular expression. Each regex segment matches a specific part of the target text such as literal text, numbers, or whitespace.
To build a regular expression, follow these steps.
-
Open the Regex Segments flyout.
Initially, the flyout appears with an empty regex segment.
- Define the regex segment.
-
Select an item from the Type list.
The available items are Text, Custom, Characters, Character Range, Quick select, and Named Group. To learn more about these options, see Type.
When you select a type, the placeholder text in the Value field changes, showing instructions relevant to the selected type.
If the selected Type is Character or Character Range, the Not switch is enabled.
-
In the Value field, enter or select a value corresponding to the selected type. If you selected the Character Range type, you need to enter two values: the start and end characters that form the character range.
To learn more about values for each regex segment type, see Value.
-
From the Quantity list, select a regex quantifier.
A regex quantifier identifies the number of times to match the regex segment in the target text. The available options are One or more, Zero or one, Zero or more, Exactly, At least, and Range. If you don't select a quantifier, the regex segment is matched exactly once.
To learn more, see Quantity.
-
Optional: If the Not switch is enabled, you can select it to match the opposite of the regex segment.
To learn more, see Not.
-
-
Optional: Add more regex segments.
To add more regex segments:
-
Click (regex segment).
A new empty regex segment is added below the existing regex segments.
- Perform the previous step, Define the regex segment, on the new empty regex segment.
Add as many regex segments as you need to complete your regular expression.
-
-
Test your regex works as expected.
As you add regex segments, the full regular expression is displayed in the Resulting Regex field. You can test your regex by trying different values in the Testing field. A status message below the Testing field indicates whether or not a match for your regex is found in the Testing text. If a match is found, the specific text that matches is identified as well.
-
Click Ok.
The Regex Segments flyout closes, returning to the page where you clicked the button.
Define a regex segment
Each regex segment has a type and a value. Some regex segment types also need you to specify a number of occurrences, while some let you match the opposite of the regex segment.
Type
Every regex segment must have a type. When you select an option from the Type list, the placeholder text in the Value field changes, showing instructions relevant to the selected type.
The following Type options are available.
- Text
-
Literal text to be matched exactly.
- Custom
-
A regex expression. Use with care and ensure the expression is valid.
- Characters
-
Specific characters that can be matched in any order.
- Character Range
-
A range of characters that can be matched in any order.
- Quick select
-
A selection of shortcut options for common character classes and character sets.
- Named Group
-
A named group is a custom predefined regular expression that you can use as part of a new regex.
This option is not available until you have created the first named group. To learn more about named groups, see Managing SureFile Enterprise rules > Named groups.
Value
A regex segment's value identifies what to match and varies according to its type. Enter or select a value corresponding to the selected type.
- Text
-
Enter the case-sensitive literal text to be matched exactly.
For example,
Correspondence [. - Custom
-
Enter a valid regex expression. Use with care and ensure the expression is valid.
For example, enter
\b[A-Z][a-z]+\bto match a capitalised word. - Characters
-
Enter a set of specific characters.
For example, enter
!@#$%^&*()to match any of the special characters on the top/number row of your keyboard. - Character Range
-
Enter the start and end characters that form the character range.
For example, enter
AandHas the start and end characters, respectively, to match any character from a range that includes only the first 8 uppercase letters. - Quick select
-
Select one of the following items from the Quick select list.
Item Regex Comment Any character (except newline) .The wildcard character class matches any single character except line terminators. Whitespace \sMatches a single white space character, including space, tab, form feed, line feed, and other Unicode spaces. Not whitespace \SMatches a single character other than white space. Digit (0-9) \dMatches any digit. Equivalent to [0-9].Not a digit \DMatches any character that is not a digit. Equivalent to [^0-9].Word character (letter, digit, underscore) \wMatches any alphanumeric character from the basic Latin alphabet, including the underscore. Equivalent to [A-Za-z0-9_].Not a word character \WMatches any character that is not a word character from the basic Latin alphabet. Equivalent to [^A-Za-z0-9_].Lowercase letter (a-z) [a-z]Matches a single lowercase letter. Uppercase letter (A-Z) [A-Z]Matches a single uppercase letter. Letter (A-Z, a-z) [A-Za-z]Matches a single case-insensitive letter. Letter or digit [A-Za-z0-9]Matches a single case-insensitive letter or a single digit. Tab \tMatches a horizontal tab. New line \nMatches a linefeed. Start of line ^A boundary-type assertion that matches the beginning of input.
End of line $A boundary-type assertion that matches the end of input. Word boundary \bA boundary-type assertion that matches a word boundary. Not a word boundary \BA boundary-type assertion that matches a non-word boundary. Unicode letter \p{L}\p{ }matches a character based on its Unicode character properties, the most basic being theGeneral_Categoryproperty which includes the valuesL(Letter) andNd(Decimal Digit Number).Unicode digit \p{Nd} - Named Group
-
Select an option from the named group list.
The available options are the named groups you have defined in your SureFile rules.
This option is not available until you have created the first named group. To learn more about named groups, see Managing SureFile Enterprise rules > Named groups.
Quantity
The Quantity list is populated with the regex quantifiers which specify how many times to match a regex segment in the target text, allowing the segment to be repeated or made optional.
Select one of the following options from the Quantity list.
| Option | Regex | Comment |
|---|---|---|
| One or more | + |
Match the segment at least once. |
| Zero or one | ? |
Match the segment exactly once or not at all. |
| Zero or more | * |
Match the segment any number of times or not at all. |
| Exactly | {n} |
Enter a value identifying exactly how many times to match this segment. |
| At least | {n,} |
Enter a value identifying the minimum number of times to match this segment. |
| Range | {n,m} |
Enter two values identifying the minimum and maximum number of times to match this segment. |
If you don't select a quantifier, the regex segment is matched exactly once.
Not
The Not switch is enabled if the selected Type is Character or Character Range. For all other Type values, the Not switch is disabled.
If the Not switch is enabled, you can select it to match the opposite of the regex segment.
For example, if a segment matches lowercase letters ([a-z]), turning the Not switch on changes the segment to match everything except lowercase letters ([^a-z]).
Test your regular expression
Testing your regular expression gives you confidence that it works as expected.
As you add regex segments, the full regular expression is displayed in the Resulting Regex field. You can test your regex by trying different values in the Testing field. A status message below the Testing field indicates whether or not a match for your regex is found in the test text. If a match is found, the specific text that matches is identified as well.