Import FuelLog

This commit is contained in:
2015-09-09 22:45:27 -04:00
parent f3a7249793
commit 56dd091178
21 changed files with 500 additions and 15 deletions
+19
View File
@@ -0,0 +1,19 @@
using System.Text.RegularExpressions;
namespace MileageTraker.Web.Utility
{
public static class NameNormalizer
{
private const string NamePattern = @"(?<Last>\w+),\s*(?<First>\w+)(?:\s*)?(?<Suffix>(jr|sr|iii))?";
private static readonly Regex NameRegex = new Regex(NamePattern, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled);
public static string Normalize(string name)
{
var match = NameRegex.Match(name);
if (!match.Success)
return name;
return string.Format("{0} {1} {2}",
match.Groups["First"], match.Groups["Last"], match.Groups["Suffix"]).TrimEnd();
}
}
}