我知道这似乎很复杂,但我的意思是例如我有一个字符串
This is a text string
我想搜索一个字符串(例如:文本)。我想找到这个字符串的第一次出现,它出现在给定的另一个字符串(例如:is)之后,并且替换应该是另一个给定的字符串(例如:replace)
所以结果应该是:
This is a textreplace string
如果 text 是,This text is a text string
那么结果应该是This text is a textreplace string
我需要一种方法(赞赏扩展方法):
public static string AppendFirstOccurranceAfter(this string originalText, string after, string oldValue, string newValue)
// "This is a text string".ReplaceFirstOccurranceAfter("is", "text", "replace")