How to Extract the fields from pdf using Regex

HI,

Can you try the following sample?

mc = System.Text.RegularExpressions.Regex.Matches(strData,"^(?<INVREF>\S+)\s+(?<POSTDATE>\d{2}/\d{2}/\d{4}).*?(?<INVDATE>\d{2}/\d{2}/\d{4})\s+(?<GROSSAMOUNT>[-\d.,]+)\s+(?<TDS>[-\d.,]+)\s+(?<AMOUNT>[-\d.,]+)",System.Text.RegularExpressions.RegexOptions.Multiline)

Then, set the following at ArrayRow

{m.Groups("INVREF").Value,DateTime.ParseExact(m.Groups("POSTDATE").Value,"dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture),DateTime.ParseExact(m.Groups("INVDATE").Value,"dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture),m.Groups("GROSSAMOUNT").Value,m.Groups("TDS").Value,m.Groups("AMOUNT").Value}

Sample20230120-3L.zip (4.1 KB)

Regards,

2 Likes