How to empty a System.Collections.IEnumerable of Regular Expressions Matches

I am assigning a variable with matches of regular expression.
And running a for each loop on the same variable.
I want to empty the variable before each loop
How do i do that?

Use {}

Hi @Rakshit,
When you run the loop every time it will automatically empty the IEnumberable, because you are not initialising the collection you are just assigning the matches output to this variable.

Let us know if this helps.
Regards,
Pavan H

Hi @pavanh003,
Thanks for the quick reply:)

The IEnumberable is not getting reset here.
I am looking for email id’s using regex, which gets saved in the variable.

And i see that the previous extracted data still displaying.

Hi @Vijay_Tulsalkar,

This doesn’t work for me.

@Rakshit

{} should work as it is Re-initializing the array

Hi,
When you use a for loop and use matches activity there and you save to a ienumberable match collection you can save to datatable and then the second time when you go to next loop it will extract the data to the same collection but it will be for only that perticular item and this sholud work,

Let us know if this doesn’t work.
Regards,
Pavan H

@Rakshit
you can re-initialize the variable before foreach as

variable = new List(of system.text.RegularExpressions.Match)

OR

variable = {}

1 Like

Hi @Vijay_Tulsalkar,
The below code worked
variable = new List(of system.text.RegularExpressions.Match)
Thanks for the help

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.