Here is the link for the my earlier post Regex with multiple repetation
I am trying to use the same regex pattern
Regex regex_pname = new Regex(@"--(?<PName>8W1_.*?)--.*?(?<MType>PTP|LIN).*?(?<PointNa>" +list[i]+")", RegexOptions.Singleline);
Where List[i]
contain a array of string
List[0]=SG006565
List[1]=SG0004254
Linst[2]=SG0004249
for inserting a for loop I would like to find the correct Matching Group (PName) which contain string like 8W1_805_431____0210_A01_0001_L
Here is link of the input string http://freetexthost.com/o6yb1gp0oh
Here is my piece of code
for (int i = 0; i < list.Count; i++) // Loop with for.
{
Regex regex_pname = new Regex(@"--(?<PName>8W1_.*?)--.*?(?<MType>PTP|LIN).*?(?<PointNa>" +list[i]+")", RegexOptions.Singleline);
Console.Write("Regex \n"+ regex_pname + "\n ");
foreach (Match Match21 in regex_pname.Matches(text))
{
GroupCollection groups = Match21.Groups;
//Console.Write("Match 21 \n" + Match21 + "\n ");
string v = groups["PName"].ToString();
//Console.WriteLine("PName \n" + v + "\n PName \n");
listView1.Items.Add(v);
}
}
When i try to run this code it always gives me first match
(8W1_803_015____0210_A01_0001_R)
three times.