diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-17 10:32:31 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-17 10:32:31 -0400 |
| commit | 37f0e23bf421ba3626d3768c5b59341eac1f540a (patch) | |
| tree | 685ec061f61bf7ea36b709e208ffcc8acf98ca7f /MediaBrowser.Common/Extensions/BaseExtensions.cs | |
| parent | 3b41f9cd2387734ef8a8342a33e0612043e9b0ff (diff) | |
fixes #538 - Support additional artist splitting
Diffstat (limited to 'MediaBrowser.Common/Extensions/BaseExtensions.cs')
| -rw-r--r-- | MediaBrowser.Common/Extensions/BaseExtensions.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/MediaBrowser.Common/Extensions/BaseExtensions.cs b/MediaBrowser.Common/Extensions/BaseExtensions.cs index 6d95cfa57..452c47159 100644 --- a/MediaBrowser.Common/Extensions/BaseExtensions.cs +++ b/MediaBrowser.Common/Extensions/BaseExtensions.cs @@ -20,10 +20,41 @@ 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(); } /// <summary> + /// Replaces the specified STR. + /// </summary> + /// <param name="str">The STR.</param> + /// <param name="oldValue">The old value.</param> + /// <param name="newValue">The new value.</param> + /// <param name="comparison">The comparison.</param> + /// <returns>System.String.</returns> + 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(); + } + + /// <summary> /// Gets the M d5. /// </summary> /// <param name="str">The STR.</param> |
