You can use regular expressions to detect information on invoices that can be used to automatically assign cost objects to invoice line items. This improves automation and provides greater flexibility in customizing extraction logic.
For example, a company operates across multiple locations: offices, warehouses, plants, and sites. Each location has its own cost center, which suppliers reference on their invoices. You use the cost center code listed on the invoice to automatically assign invoice line items to the corresponding cost object.
⚠️ Caution
A regex rule extracts a single reference from an invoice and uses it to assign the same cost object to all line items. It doesn’t extract a separate reference for each line item.
Regex string matching takes precedence over any other assignment logic, including smart coding. For example, if a regex is defined for cost objects but no invoice references match the pattern, or Yokoy is unable to find a corresponding cost object, then the cost object field is updated using other active logic such as smart coding or default values.
Perk automatically compares the regex-extracted reference to all values of the selected attribute on active cost objects in the company (cost objects must have the Invoices scope selected). When it finds a match, it assigns the matching cost object to all line items. If multiple matches are found, then the cost object field in the line items of the invoice is left empty.
Only exact matching of values is allowed; no fuzziness. This feature only works with PDF invoices; XML-based e-invoices are not supported.
Multiple regex rules can be defined for cost objects. If multiple rules match values for the same invoice, no cost object is assigned and the field is left empty.
Creating a rule to assign cost objects
To create a cost object regex rule:
Go to Invoice business rules > String matching (Regex) tab.
Click the Add regex button.
To create a new rule, enter the following information:
Field | Description |
Regex syntax | Regex expressions is a special type of language that allows us to recognize certain patterns.
|
Matched object attribute | Specifies the data field Yokoy matches against the string extracted by the regex from the invoice. Currently, you can only match against specific field values in Category:
|
Target invoice field placement | Specifies where the target field is located. In this case, select Line item. |
Target invoice field | Indicates the invoice field to which the matched value is assigned. In this case, it should be Cost object. |
Click Save to keep the rule without activating, or Activate to apply the rule to any new invoice uploaded.
Possible setup for assigning a cost object
You receive invoices from multiple suppliers and want each invoice line item to be automatically assigned to the corresponding cost object. Suppliers are asked to include a unique reference in the invoice that identifies the cost center, as specified on the order request. All cost center references follow a specific format: the letters CC, a dash, followed by four digits, such as CC-4000 for Assembly Line B.
You set up a rule to:
Define a recognition pattern for this reference using a regex rule (e.g.
CC-\d{4}).Select the Cost object data field that should be matched – in this case, the Cost object code (ERP).
Select Line item as the field placement.
Select Cost object as the target invoice field.
Regex rule to assign the cost object
Code associated with the cost object
For every newly uploaded invoice (whether uploaded manually or via email), Yokoy scans the PDF to detect a string that matches the specified regex pattern. When a match is found, Yokoy compares it against the ERP codes stored in the cost object records and automatically assigns all invoice line items to the cost object where ERP code matches the detected value (e.g. CC-4000 for Assembly Line B).




