How to loop

How do I loop for each item in Filecontents
Eg:
Input
“”,
“CUSTOMERS. ALL PARTS REMAIN THE PROPERTY OF UK Total VAT Amount £122.13”,
“”,
“TRUCKREPAIRS LTD UNTIL PAID FOR IN FULL. THIS IS YOUR”,
“”,
“ORIGINAL & ONLY INVOICE Invoice Total £732.77”,
“”,
“”,
“”,
“Reg. No. 10602802 England VAT No. 261600535”,
“”,
“Registered Office: UK Truckrepairs Ltd,
147a High Road,
Waltham Cross,
Herts,
EN8 7AP”,
“”,
“”,
“”,

I need - Invoice Total £732.77 as O/P , using assign activity

Hi @nidhi.kowalli1

Use the regex expression in assign activity.

Regards

can you tell us more about

what data type it is and from which source the variable value is coming from. Thanks

HI @nidhi.kowalli1

Check the below regex:


Input = “”,
“CUSTOMERS. ALL PARTS REMAIN THE PROPERTY OF UK Total VAT Amount £122.13”,
“”,
“TRUCKREPAIRS LTD UNTIL PAID FOR IN FULL. THIS IS YOUR”,
“”,
“ORIGINAL & ONLY INVOICE Invoice Total £732.77”,
“”,
“”,
“”,
“Reg. No. 10602802 England VAT No. 261600535”,
“”,
“Registered Office: UK Truckrepairs Ltd,
147a High Road,
Waltham Cross,
Herts,
EN8 7AP”,
“”,
“”,
“”,

Output = System.Text.RegularExpressions.Regex.Match(Input,"(INVOICE.*\d+)").Value

Regards

@nidhi.kowalli1

Assign: InvoiceTotal = System.Text.RegularExpressions.Regex.Match(FileContents.ToString, "Invoice Total\s*\£\s*\d+\.\d+").Value

Hi @nidhi.kowalli1

Input = {"",
"CUSTOMERS. ALL PARTS REMAIN THE PROPERTY OF UK Total VAT Amount £122.13",
"",
"TRUCKREPAIRS LTD UNTIL PAID FOR IN FULL. THIS IS YOUR",
"",
"ORIGINAL & ONLY INVOICE Invoice Total £732.77",
"",
"",
"",
"Reg. No. 10602802 England VAT No. 261600535",
"",
"Registered Office: UK Truckrepairs Ltd,
147a High Road,
Waltham Cross,
Herts,
EN8 7AP",
"",
"",
""}

Assign-> result = Input.Where(Function(x) x.Contains("Invoice Total")).FirstOrDefault()

FileContents: Data type: Array of String

then a LINQ Where can help

strFirstLine =
FileContents.Where(Function (x) x.Contains("Invoice Total £")).FirstOrDefault

and we can combine it with a regex to cutout more the detail part

EDITED: grammar and statement formulation

Hi @nidhi.kowalli1

Please check the below flow:

Input = {"",
"CUSTOMERS. ALL PARTS REMAIN THE PROPERTY OF UK Total VAT Amount £122.13",
"",
"TRUCKREPAIRS LTD UNTIL PAID FOR IN FULL. THIS IS YOUR",
"",
"ORIGINAL & ONLY INVOICE Invoice Total £732.77",
"",
"",
"",
"Reg. No. 10602802 England VAT No. 261600535",
"",
"Registered Office: UK Truckrepairs Ltd,
147a High Road,
Waltham Cross,
Herts,
EN8 7AP",
"",
"",
""}

Assign-> Output= Input.Where(Function(x) x.Contains("Invoice Total")).FirstOrDefault()

Result= System.Text.RegularExpressions.Regex.Match(Output,"(?<=INVOICE\s)(.*\d+)").Value

Regards

2 Likes

strText =

(From s in FileContents
Where Contains("Invoice Total £")
Let m = Regex.Match(s, "Invoice Total.*")
Where m.Success
Select v  = m.Value).FirstOrDefault

What if the Key name" Invoice Total" Is dynamic?
example, in some file its, “Invoice Total” and some file its “Total Invoice Amount”

Hi @nidhi.kowalli1

Try this . This should work.

Regards

@nidhi.kowalli1

System.Text.RegularExpressions.Regex.Match(FileContents.ToString, "(Invoice Total|Total Invoice Amount)\s*\£\s*\d+\.\d+").Value

Hi @nidhi.kowalli1

Use the below syntaxes in Assign:

Assign activity-> Input = {"", "CUSTOMERS. ALL PARTS REMAIN THE PROPERTY OF UK Total VAT Amount £122.13", "", "TRUCKREPAIRS LTD UNTIL PAID FOR IN FULL. THIS IS YOUR", "", "ORIGINAL & ONLY INVOICE Invoice Total £732.77", "", "", "", "Reg. No. 10602802 England VAT No. 261600535", "", "Registered Office: UK Truckrepairs Ltd, 147a High Road, Waltham Cross, Herts, EN8 7AP", "", "", ""}

Assign activity -> Output = Input.Where(Function(x) x.Contains("Invoice Total")).FirstOrDefault()

Assign activity -> Result = System.Text.RegularExpressions.Regex.Match(Output,"(?<=INVOICE\s)(.*\d+)").Value

Input is of DataType Array(System.String). Output and Result is of DataType System.String


Regards

Hi,
This expression is giving me Null value!!

Because I have multiple words in pdf saying “INVOICE”