I think you can use the overload of Regex.Replace to specify the maximum number of times to replace…
var regex = new Regex(Regex.Escape("o"));
var newText = regex.Replace("Hello World", "Foo", 1);
More Related Contents:
- extract number out strings c# [closed]
- RegEx to remove key and certificate headers and footers [duplicate]
- c# Regular Expression for the text below? [closed]
- Get string between two strings in a string
- Simple and tested online regex containing regex delimiters does not work in C# code
- Using RegEx to balance match parenthesis
- Using String Format to show decimal up to 2 places or simple integer
- regular expression for finding ‘href’ value of a link
- Regex to strip line comments from C#
- split a comma-separated string with both quoted and unquoted strings [duplicate]
- Regular expression for decimal number
- How to keep the delimiters of Regex.Split?
- How to find multiple occurrences with regex groups?
- Getting overlapping regex matches in C#
- Regex: C# extract text within double quotes
- .Net regex matching $ with the end of the string and not of line, even with multiline enabled
- How do I filter all HTML tags except a certain whitelist?
- Why \b does not match word using .net regex
- RegEx for an IP Address
- Regex word boundary expressions
- Regex to match all us phone number formats
- How to remove numbers from string using Regex.Replace?
- .Net regex: what is the word character \w?
- Canadian postal code validation
- Regex to match a word with + (plus) signs
- c# regex matches example
- Using Directory.GetFiles with a regex in C#?
- C# regex pattern to extract urls from given string – not full html urls but bare links as well
- using static Regex.IsMatch vs creating an instance of Regex
- regex to split line (csv file)