websitepanel/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Extensions/StringExtensions.cs
2015-04-30 04:24:15 -07:00

22 lines
No EOL
686 B
C#

namespace WebsitePanel.WebDav.Core.Extensions
{
public static class StringExtensions
{
public static string ReplaceLast(this string source, string target, string newValue)
{
int index = source.LastIndexOf(target);
string result = source.Remove(index, target.Length).Insert(index, newValue);
return result;
}
public static string Tail(this string source, int tailLength)
{
if (source == null || tailLength >= source.Length)
{
return source;
}
return source.Substring(source.Length - tailLength);
}
}
}