i have an issue - i am using a for each loop in order to extract with Regex some information from different invoices.
And i have an issue with a loop, because if the information doesn’t exist in that certain invoice, it will write the last value it found in a previous invoice. I can’t figure out how to reset the variable before the loop.
Approach 1:
So you could do the check in an earlier If condition match.count>0 then go into the for each loop. This way you can remove the Then branch and keep it empty as this condition will already have been checked by the outer If condition.
Finally row.item("Value") / row("Value") can be assigned to the item.ToString in match. Where item.ToString is the extracted string from your regex expression.
Finally when that row is processed you set the match variable to either {}, Nothing, or New List(of System.Text.RegularExpressions.Match)
Also kindly check the alternative suggestion I provided in the post above. That way you will do the data validation for “match” variable. If the matches is null you avoid the For Each —>Match.