文字列内の最後の単語を置き換える必要があるという問題があります。
状況:次の形式の文字列が与えられました。
string filePath ="F:/jan11/MFrame/Templates/feb11";
次に、次のように置き換えTnaName
ます。
filePath = filePath.Replace(TnaName, ""); // feb11 is TnaName
これは機能しますが、 が私TnaName
の と同じ場合に問題がありfolder name
ます。これが発生すると、次のような文字列が得られます。
F:/feb11/MFrame/Templates/feb11
これで、両方の出現箇所が に置き換えられましTnaName
たfeb11
。文字列の最後の単語のみを置き換える方法はありますか?
注:これfeb11
はTnaName
別のプロセスからのものです-それは問題ではありません。