using System;
using System.Text.RegularExpressions;
public class Test
{
public static void Main()
{
String text = "/green/blah/agriculture/apple/blah/hallo/apple/green/blah/agriculture/apple/blah/hallo/apple";
var regex = new Regex(Regex.Escape("apple"));
String replacement = "Orange";
string result = regex.Replace(text, replacement.ToString(), 1);
Console.WriteLine(result);
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uVGV4dC5SZWd1bGFyRXhwcmVzc2lvbnM7CgpwdWJsaWMgY2xhc3MgVGVzdAp7CglwdWJsaWMgc3RhdGljIHZvaWQgTWFpbigpCgl7CiAgICBTdHJpbmcgdGV4dCA9ICIvZ3JlZW4vYmxhaC9hZ3JpY3VsdHVyZS9hcHBsZS9ibGFoL2hhbGxvL2FwcGxlL2dyZWVuL2JsYWgvYWdyaWN1bHR1cmUvYXBwbGUvYmxhaC9oYWxsby9hcHBsZSI7Cgl2YXIgcmVnZXggPSBuZXcgUmVnZXgoUmVnZXguRXNjYXBlKCJhcHBsZSIpKTsKICAgIFN0cmluZyByZXBsYWNlbWVudCA9ICJPcmFuZ2UiOwogICAgc3RyaW5nIHJlc3VsdCA9IHJlZ2V4LlJlcGxhY2UodGV4dCwgcmVwbGFjZW1lbnQuVG9TdHJpbmcoKSwgMSk7CiAgICBDb25zb2xlLldyaXRlTGluZShyZXN1bHQpOwoJfQp9