[ALL] Take care of possible null strings

This commit is contained in:
Matt Nadareski
2017-12-14 13:22:22 -08:00
parent 296fc2154c
commit e8d59e6970
9 changed files with 30 additions and 30 deletions

View File

@@ -42,13 +42,13 @@ namespace NaturalSort
if (!table.TryGetValue(x, out string[] x1))
{
//x1 = Regex.Split(x.Replace(" ", ""), "([0-9]+)");
x1 = Regex.Split(x.ToLowerInvariant(), "([0-9]+)").Where(s => s != "").ToArray();
x1 = Regex.Split(x.ToLowerInvariant(), "([0-9]+)").Where(s => !String.IsNullOrWhiteSpace(s)).ToArray();
table.Add(x, x1);
}
if (!table.TryGetValue(y, out string[] y1))
{
//y1 = Regex.Split(y.Replace(" ", ""), "([0-9]+)");
y1 = Regex.Split(y.ToLowerInvariant(), "([0-9]+)").Where(s => s != "").ToArray();
y1 = Regex.Split(y.ToLowerInvariant(), "([0-9]+)").Where(s => !String.IsNullOrWhiteSpace(s)).ToArray();
table.Add(y, y1);
}