Regex.Replace, especially RegEx.Replace(string, string, int), is probably what you're looking for. That or String.IndexOf which will give you the index and then you can cut and rebuild the string with the new text you want.
An example demonstrating the latter (as first demonstrated by @David Humpohl):
Taking the "first only" into account, perhaps:
?
Or more generally:
Then:
In C# syntax:
Regex.Replace, especially RegEx.Replace(string, string, int), is probably what you're looking for. That or String.IndexOf which will give you the index and then you can cut and rebuild the string with the new text you want.
An example demonstrating the latter (as first demonstrated by @David Humpohl):
will find first
F
inInputString
and replace it withR
.For anyone that doesn't mind a reference to
Microsoft.VisualBasic
, there is theReplace
Method:Take a look at Regex.Replace.