COPY
Singapore 408942 Registration No : 199802208C GST Registration No : M9-0005650-C Tax Invoice No : 8000010691 Invoice Date : 25.08.2020 Sales Order No : 3600011123 Customer ID : 1000000464 Payment Terms : 30 days Due Date : 24.09.2020 Page No : Page 1 of 1
Qty Unit Price Amount SGD
Hi @supermanPunch , i am still new to Uipath, wasn’t aware that there is a single regex expression though. I am fine with either way. I tried using Matches activity to extract the 2 values, it did populate the values but my text diff from invoice to invoice.
Therefore, am not sure why this time round, the regex expression is not able to pick up the values…
We would also need to check on different samples and create/prepare the regex so that it can accept all the formats available.
Are the number of formats in which the text appears not known, can it any format it any way ? or is it finite ? Do we also have always a Key Value pair that we would need to look at always ?
Above points would need to be considered when formats of text vary.
Let us know if you could do the above on your own and provide us with the necesary unique formats that you may receive so that we can work on creating the appropriate regex pattern.
In your regex you have a specific name used as a anchor, for example “invoice number:” If the specific is available in the document, it will extract the values, otherwise it won’t.
In such case, we have provided all possible issues with “|” this separation, which means “OR” in regex.
(?<=Tax Invoice No : )(\d+)|(?<=Tax Invoice no : )(\d+)|(?<=Tax Invoice Number : )(\d+)
@Gokul_Jayakumar , i tried the regex expression you have provided and still unable to extract both the invoice and account no.
I tried using Matches, it didn’t populate any values either…
system.text.RegularExpressions.Regex.Matches(strInvoiceText,“(?<=Tax Invoice No : )(\d+)|(?<=Customer ID : )(\d+)”)(0) for 1st match
system.text.RegularExpressions.Regex.Matches(strInvoiceText,“(?<=Tax Invoice No : )(\d+)|(?<=Customer ID : )(\d+)”)(1) for 2nd match
Hi @Gokul_Jayakumar , do i use multiple assign activity or matches activity for the regex expression?
Because when i use the regex expression provided in a multiple assign activity, it throws out an error stating:
RemoteException wrapping System.InvalidOperationException: Can not assign 'system.text.RegularExpressions.Regex.Matches(strInvoiceText,“(?<=Tax Invoice No : )(\d+)|(?<=Customer ID : )(\d+)”)(1).value to ‘strInvoiceNumber’. —> RemoteException wrapping System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.Parameter name: i
@Justine
It’s better to use separate assig activities for each data.
If the data is available in the text, it returns the value, otherwise it results in an empty value. No error will occur.
i try using the single assign activity and paste the formula
system.text.RegularExpressions.Regex.Matches(strInvoiceText,“(?<=Tax Invoice No : )(\d+)|(?<=Customer ID : )(\d+)”)(0).tostring
it throws out an error stating:
Assign: Specified argument was out of the range of valid values.
Parameter name: i
Tried excluding .totstring and an error populated stating:
Assign:Object reference not set to an instance of an object
tried searching the forum for the other alternatives by adding a Matches and assign activity, same error still populated; Assign:Object reference not set to an instance of an object.
If you need to find the total number of matches available in txt document try this
system.text.RegularExpressions.Regex.Matches(strInvoiceText,“(?<=Tax Invoice No : )(\d+)|(?<=Customer ID : )(\d+)”).count.tostring
If you were able to solve your issue, please do post the solution (a bit more in detail - an extended expression) or mark the appropriate suggestion post as solution, so that we could close the topic.
Below are the formula used to extract both Invoice no and Account no using the Indexof in a Multiple Assign Activity.
strInvoiceText.Substring(strInvoiceText.IndexOf(“Invoice No “)+“Invoice No “.Length,1302).Split(Environment.NewLine.ToCharArray)(0).Trim.Replace(”:”,””)