Replace the last occurrence of a word in a string - C#

前端 未结 7 1940
星月不相逢
星月不相逢 2020-12-09 14:07

I have a problem where I need to replace the last occurrence of a word in a string.

Situation: I am given a string which is in this format:

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-09 15:01

    var lastIndex = filePath.LastIndexOf(TnaName);
    
    filePath = filePath.Substring(0, lastIndex);
    

提交回复
热议问题