Link Search Menu Expand Document

How to parse Invoice Number

In this step by step guide you will learn how to parse invoice numbers with different formats using one template.

  1. First, create a new Document Parser template using the Online Template Editor.

  2. Next, click the Load Test PDF or Image button and select your source file.

  3. Then, click the +Add Objects button.

  4. Select Add FIELD based on TEXT SEARCH.

  5. You can use the Name field to rename the object. Let’s name it invoiceId.

  6. Paste this Regex pattern in the Expression field.

(?is)(?:\bInvoice|\bNumber).*?(?<value>(?-i)INV-[A-Z0-9]+)( |\r?$)

  1. Repeat steps 3 to 5. This time use the name invoiceIdFallback.

  2. And paste this 2nd pattern in the Expression field.

(?i)(?:Invoice Number|Invoice #|Invoice No\.?|Receipt No\.?|CREDIT NOTE No\.?|REF NO\.?)\s*:?\s+(?<value>.*?)( |\r?$)

  1. Repeat steps 3 to 5 again. Now use the name invoiceIdFallback2.

  2. This time paste this 3rd pattern in the Expression field.

(?i)(?:\bInvoice|\bNumber)\s*:?\s+(?<value>.*?)( |\r?$)

  1. Click the Edit Template button.

  2. Scroll down until you see the object for invoiceIdFallback.

  3. Add the line "coalesceWith": "invoiceId" after "regex": true.

  4. Add the same line for invoiceIdFallback2.

{
"name": "invoiceId",
"objectType": "field",
"fieldProperties": {
"fieldType": "macros",
"expression": "(?is)(?:\\bInvoice|\\bNumber).*?(?<value>(?-i)INV-[A-Z0-9]+)( |\\r?$)",
"regex": true
},
"id": 2
},
{
"name": "invoiceIdFallback",
"objectType": "field",
"fieldProperties": {
"fieldType": "macros",
"expression": "(?i)(?:Invoice Number|Invoice #|Invoice No\\.?|Receipt No\\.?|CREDIT NOTE No\\.?|REF NO\\.?)\\s*:?\\s+(?<value>.*?)( |\\r?$)",
"regex": true,
"coalesceWith": "invoiceId"
},
"id": 3
},
{
"name": "invoiceIdFallback2",
"objectType": "field",
"fieldProperties": {
"fieldType": "macros",
"expression": "(?i)(?:\\bInvoice|\\bNumber)\\s*:?\\s+(?<value>.*?)( |\\r?$)",
"regex": true,
"coalesceWith": "invoiceId"
},
"id": 4
}
  1. Click the Run Template button and test it with your different documents.

You can explore our Document Parser API Docs here. For any questions, feel free to contact our support team.