I have Power Automate Desktop v2.48.153 on Windows 10. I'm trying to extract data from a PDF which has many invoices. I need to save each individual invoice as it's own PDF using the invoice number as the file name of the output PDF files.
Here are the relevant steps I do.
- Find the line with "Customer name" in it, and get the next line which has the invoice number.
- Split the line with the invoice number by spaces into a list.
- Loop through that list to find a 6 digit number which is the invoice number, using the regex() function. This is the part that is not working when I step through the steps and look at the variables. If the invoicenum is found then assign it to the variable InvoiceNum and exit the loop early.
Here's how I search for that invoice number in the line of data which has it:
- If regex(variables(%CurrentItem%), '^\d{6}$') equal to True then
- set variable InvoiceNum to CurrentItem and exit loop early. This never gets executed. I've also tried this as my regex by having 0 or more spaces before and after the CurrentItem: regex(variables(%CurrentItem%), '^ *\d{6} *$')
Could there be some hidden characters in there that I have to filter out? How would I do that?
What could I be doing wrong here?
It seems the regex() function isn't working. I'm pretty familiar with regex as well.
Thank you.