1

Can not extract desired value between two tags

string pattern = @"<tag1>(.*?)</tag1>";
string input = "cut losses quickly morenonxmldata<tag1>0002</tag1>morenonxmldata";
foreach (Match match in Regex.Matches(input, pattern))
Console.WriteLine("'{0}// found at index {1}.", match.Value, match.Index);

Output: <tag1>0002</tag1>

I need: 0002

I use regexstorm.net as regexp tester and it gives me the following result:

Matched string: <tag1>0002</tag1>
$1: 0002

What does $1 mean? The result i need is assigned to this variable. How can i access it and what am i doing wrong? Please help. Spent whole day for finding the answer.

Diego Slinger
  • 139
  • 11

0 Answers0