Simplify `MovieImporter.SingleSpaces`
This commit is contained in:
parent
759784a648
commit
ad8b4653d4
|
@ -2,6 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
using BizHawk.Common;
|
using BizHawk.Common;
|
||||||
|
|
||||||
|
@ -122,22 +123,11 @@ namespace BizHawk.Client.Common
|
||||||
return str.Trim();
|
return str.Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Regex WhitespacePattern = new(@"\s+");
|
||||||
|
|
||||||
// Reduce all whitespace to single spaces.
|
// Reduce all whitespace to single spaces.
|
||||||
protected static string SingleSpaces(string line)
|
protected static string SingleSpaces(string line)
|
||||||
{
|
=> WhitespacePattern.Replace(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ends the string where a NULL character is found.
|
// Ends the string where a NULL character is found.
|
||||||
protected static string NullTerminated(string str)
|
protected static string NullTerminated(string str)
|
||||||
|
|
Loading…
Reference in New Issue