fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. String text = "/green/blah/agriculture/apple/blah/hallo/apple/green/blah/agriculture/apple/blah/hallo/apple";
  9. var regex = new Regex(Regex.Escape("apple"));
  10. String replacement = "Orange";
  11. string result = regex.Replace(text, replacement.ToString(), 1);
  12. Console.WriteLine(result);
  13. }
  14. }
Success #stdin #stdout 0.1s 24664KB
stdin
Standard input is empty
stdout
/green/blah/agriculture/Orange/blah/hallo/apple/green/blah/agriculture/apple/blah/hallo/apple