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
As far as I can remember there is no direct function and so you need to be splitting it then replacing the string and then concatenate it back to get the complete string.
yeah i thought of that option too but the problem seems to be it wont let me split it on such a long combination of characters such as "i_love_c#"
this solution might help you string a = @"abc def ghijklmnopwxyzabcdefghijklmnop"; a = System.Text.RegularExpressions.Regex.Replace(a, "^(a)b(c)", "yogesh"); Response.Write(a.ToString());