Regex same item few times - Choose the item I want

Dear all,

I am trying to automate an invoice, so we post automatically. I am facing a issue related to the times that an item appears. I want to get the invoice number, but the problem is that “invoice” appers few times.

If I know that the invoice number is in the third “invoice”. How could I do it to get it?

Many thanks!:slight_smile:

Hi. Could you please an example and the output you want?

Of Course! As there are private information, I will try to put an example. This is what I moreless have:


Invoice Date mm/dd/yyyy

Name of the company, C999abcdef Invoice A0B00000

In this example, I need “A0B00000”. The code “C999abcdef” I know I could use it to get the invoice number:

(?<=C999abcdef Invoice\s+)\w+

The problem is that maybe next year or next months this code can change. So I would like to know if there is the possibility to get the invoice number without using this code.

Many thanks :slight_smile:

@Angel_Llull - Could you please try this…


Regex Pattern: (?<=Name of the company, \w+\sInvoice\s).*