MetaServer > Help > Extract > Find with Regular Expression

120-330 Find with Regular Expression

With MetaServer’s Find with Regular Expression rule, you can use regular expressions to return correct data from your source text.

This rule is targeted to advanced users who need to expand upon the already integrated mask construction, as seen in the Find Word with Mask / Word(s), Find Line with Mask / Word(s) and Find Word Group with Mask / Word(s) rules.

If you are interested in learning RegEx, please refer to this website:
https://regexr.com/

Find with Regular Expression rules are defined in a MetaServer Extract or Separate Document / Process Page action.

To add this rule, press the Add button and select Find –> with Regular Expression.

After extracting the full text, we want to find the account number, using regular expressions.

TIP: The thumbnail on the right will follow you, so you can easily refer to the Setup window. Click on the thumbnail to make the image larger.

First, add a description to your rule. Then, select the field that will hold the result.

01 – Source field: press the drop-down arrow to select the source field. This is the field containing the text you want to filter using regex.

02 – Expression: enter your regular expression here. The regex will be immediately applied to the below example text and the result will be shown in the text box. below the example box.

NOTE: you can hover over the information badge for an overview of some popular regular expressions. You can also refer to the list below.

Character Classes Description
. any character
\w \d \s word, digit, whitespace
\W \D \S not word, digit, whitespace
[abc] any of a, b, or c
[^abc] not a, b, or c
[A-Za-z] character between A-Z and a-z
[A-Za-z\p{L}]*

characters between A-Z and a-z and all accented characters, upper and lower case,
like those used in French, German, Swedish etc.

 

Anchors Description
^abc$ start / end of the string
\babc\b word boundary matches abc exactly

 

Quantifiers & Alternation
Description
a{5} exactly five
a{2,} two or more
a{1,3} between one & three
ab|cd match “ab” or “cd”
a* 0 or more
a+ 1 or more
a? 0 or 1

03 – Example: enter or copy example text you would like to test your regex on. The result will be shown in the result box below.

04 – Value: You can specify which words you want to keep. There are 3 options:

1) Keep all matches: this will return all words matching the defined regex.

2) Keep first match: this will return the first word matching the defined regex.

3)  Keep last match: this will return the last word matching the defined regex.

Note: If you want to output a specific word of many, like the 2nd word of 5 words, extract all words by keeping all matches and create an Edit / Set Field Value rule to extract the specific word using the Extract segments options.

05 – Overwrite: if enabled, the result will overwrite the previous field value. Otherwise, the result will be added to the value that is already in the field.

06 – Clear field if result is blank: if the result is blank, any values already in the index field are cleared.

07Delete duplicates: this will delete all duplicate matches and the result will only consist of unique values.

TIP: you can copy the current settings and paste them in another setup window of the same type. Do this by pressing the Settings button in the bottom left of the Setup window and by selecting Copy. Then open another setup window of the same type and select Paste.

Subscribe to our Newsletter


Please check the box below to agree to the privacy policy and continue *


NOTE: if you're experiencing trouble with submitting this form, please try again using another browser.