From 37f0e23bf421ba3626d3768c5b59341eac1f540a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 17 Sep 2013 10:32:31 -0400 Subject: fixes #538 - Support additional artist splitting --- MediaBrowser.Common/Extensions/BaseExtensions.cs | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'MediaBrowser.Common/Extensions/BaseExtensions.cs') diff --git a/MediaBrowser.Common/Extensions/BaseExtensions.cs b/MediaBrowser.Common/Extensions/BaseExtensions.cs index 6d95cfa576..452c471593 100644 --- a/MediaBrowser.Common/Extensions/BaseExtensions.cs +++ b/MediaBrowser.Common/Extensions/BaseExtensions.cs @@ -20,9 +20,40 @@ namespace MediaBrowser.Common.Extensions { // http://stackoverflow.com/questions/1349023/how-can-i-strip-html-from-text-in-net const string pattern = @"<(.|\n)*?>"; + return Regex.Replace(htmlString, pattern, string.Empty).Trim(); } + /// + /// Replaces the specified STR. + /// + /// The STR. + /// The old value. + /// The new value. + /// The comparison. + /// System.String. + public static string Replace(this string str, string oldValue, string newValue, StringComparison comparison) + { + var sb = new StringBuilder(); + + var previousIndex = 0; + var index = str.IndexOf(oldValue, comparison); + + while (index != -1) + { + sb.Append(str.Substring(previousIndex, index - previousIndex)); + sb.Append(newValue); + index += oldValue.Length; + + previousIndex = index; + index = str.IndexOf(oldValue, index, comparison); + } + + sb.Append(str.Substring(previousIndex)); + + return sb.ToString(); + } + /// /// Gets the M d5. /// -- cgit v1.2.3