im trying to find a way in c# to replace first occurance of a regular expression in a string.
so if string = " found 1 found 2 found 3"
i want to do something like :
string = replacefirst("found","")
to give results:
string = " 1 found 2 found 3"
thanx
Replace first occurance
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

AlanRank #669 · 3.6K reputationPosted Jun 25, 2007, 1:06 AM EDT
using System.Text.RegularExpressions;
........
string s = " found 1 found 2 found 3";
Regex r = new Regex("found ");
s = r.Replace(s, "", 1);