fork(16) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static string getReplacementNumber(int i)
  7. {
  8. return string.Format("<{0}>", i);
  9. }
  10.  
  11. public static void Main()
  12. {
  13. string input = "abc foo abc bar abc";
  14. Regex rx = new Regex("abc");
  15. int i = 0;
  16. string result = rx.Replace(input, match => { return getReplacementNumber(i++); });
  17. Console.WriteLine(result);
  18. }
  19. }
Success #stdin #stdout 0.05s 37240KB
stdin
Standard input is empty
stdout
<0> foo <1> bar <2>