Use regex to replace multiple spaces with one space

This communicates the intent of the code more clearly than before.
No noticeable performance impact.
pull/1704/head
Andrew Rabert 5 years ago
parent 6478cd2ea4
commit 907b3185c2

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
@ -312,14 +313,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
} }
sb.Replace(", the", string.Empty).Replace("the ", " ").Replace(" the ", " "); sb.Replace(", the", string.Empty).Replace("the ", " ").Replace(" the ", " ");
int prevLength; return Regex.Replace(sb.ToString().Trim(), @"\s+", " ");
do
{
prevLength = sb.Length;
sb.Replace(" ", " ");
} while (sb.Length != prevLength);
return sb.ToString().Trim();
} }
private void MapSeriesToResult(MetadataResult<Series> result, TvDbSharper.Dto.Series tvdbSeries, string metadataLanguage) private void MapSeriesToResult(MetadataResult<Series> result, TvDbSharper.Dto.Series tvdbSeries, string metadataLanguage)

Loading…
Cancel
Save