15 lines
386 B
C#
15 lines
386 B
C#
namespace Utils
|
|
{
|
|
public static class StringExtensions
|
|
{
|
|
public static string ReplaceLast(this string str, string oldValue, string newValue)
|
|
{
|
|
int index = str.LastIndexOf(oldValue);
|
|
|
|
return index < 0
|
|
? str
|
|
: str.Remove(index, oldValue.Length)
|
|
.Insert(index, newValue);
|
|
}
|
|
}
|
|
} |