diff --git a/src/BizHawk.Client.Common/movie/import/IMovieImport.cs b/src/BizHawk.Client.Common/movie/import/IMovieImport.cs index 189a50d72b..415ff11de8 100644 --- a/src/BizHawk.Client.Common/movie/import/IMovieImport.cs +++ b/src/BizHawk.Client.Common/movie/import/IMovieImport.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text.RegularExpressions; using BizHawk.Common; @@ -122,22 +123,11 @@ namespace BizHawk.Client.Common return str.Trim(); } + private static readonly Regex WhitespacePattern = new(@"\s+"); + // Reduce all whitespace to single spaces. protected static string SingleSpaces(string line) - { - line = line.Replace("\t", " "); - line = line.Replace("\n", " "); - line = line.Replace("\r", " "); - line = line.Replace("\r\n", " "); - string prev; - do - { - prev = line; - line = line.Replace(" ", " "); - } - while (prev != line); - return line; - } + => WhitespacePattern.Replace(line, " "); // Ends the string where a NULL character is found. protected static string NullTerminated(string str)