using System;
using System.Text.RegularExpressions;
public class Test
{
public static string getReplacementNumber(int i)
{
return string.Format("<{0}>", i);
}
public static void Main()
{
string input = "abc foo abc bar abc";
Regex rx = new Regex("abc");
int i = 0;
string result = rx.Replace(input, match => { return getReplacementNumber(i++); });
Console.WriteLine(result);
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uVGV4dC5SZWd1bGFyRXhwcmVzc2lvbnM7CgpwdWJsaWMgY2xhc3MgVGVzdAp7CglwdWJsaWMgc3RhdGljIHN0cmluZyBnZXRSZXBsYWNlbWVudE51bWJlcihpbnQgaSkKICAgICAgICB7CgkJcmV0dXJuIHN0cmluZy5Gb3JtYXQoIjx7MH0+IiwgaSk7CiAgICAgICAgfQoKCXB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKCXsKCQlzdHJpbmcgaW5wdXQgPSAiYWJjIGZvbyBhYmMgYmFyIGFiYyI7CgkJUmVnZXggcnggPSBuZXcgUmVnZXgoImFiYyIpOwoJCWludCBpID0gMDsKCQlzdHJpbmcgcmVzdWx0ID0gcnguUmVwbGFjZShpbnB1dCwgbWF0Y2ggPT4geyByZXR1cm4gZ2V0UmVwbGFjZW1lbnROdW1iZXIoaSsrKTsgfSk7CgkJQ29uc29sZS5Xcml0ZUxpbmUocmVzdWx0KTsKCX0KfQ==