You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace PhilExampleCrawler.Common.Models
|
|
|
|
|
{
|
|
|
|
|
public static class Validator
|
|
|
|
|
{
|
|
|
|
|
private const string ALLOWED = "0123456789";
|
|
|
|
|
|
|
|
|
|
/// <summary> Removes any character that is not contained in "0123456789" </summary>
|
|
|
|
|
public static string PhoneNumber_Normalize(this string phone)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(phone))
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
|
|
string p = "";
|
|
|
|
|
for (int i = phone.Length - 1; i >= 0; i--)
|
|
|
|
|
if (ALLOWED.Any(c => c == phone[i]))
|
|
|
|
|
p = phone[i] + p;
|
|
|
|
|
return p;
|
|
|
|
|
//=> phone.Trim().TrimStart('+').TrimStart('0')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|