public static int GetExpireHours(string[] p, int def = 0)
{
int ah = def;
for (int x = 0; x < p.Length; x++)
{
string r = p[x];
if (r.StartsWith("x"))
{
MatchCollection mc = Regex.Matches(r.Substring(1), @"(\d*)(d|day|days|h|hour|hours|w|week|weeks)?", RegexOptions.IgnoreCase);
if (mc.Count > 0)
{
if (mc[0].Groups.Count >= 2)
{
ah = Convert.ToInt32(mc[0].Groups[1].Value);
}
if (mc[0].Groups.Count >= 3)
{
switch (mc[0].Groups[2].Value.ToLower())
{
case "d":
case "days":
case "day":
ah = ah * 24;
break;
case "w":
case "weeks":
case "week":
ah = ah * 24 * 7;
break;
case "m":
case "months":
case "month":
ah = ah * 24 * 30;
break;
}
}
}
break;
}
}
return ah;
}