using System.Text.RegularExpressions;
public static void Main()
Console.WriteLine(CheckVatNumber("NL 8123 048 83B 01"));
private static bool CheckVatNumber(string vat)
if (string.IsNullOrEmpty(vat))
vat = Regex.Replace(vat, "(\\s|-|\\.)+", string.Empty);
Console.WriteLine("After applying regex replace: " + vat);
TimeSpan.FromMilliseconds(100));
var vatNumber = match.Groups[2].Value;
Console.WriteLine("After extracting vat number: " + vatNumber);
var multipliers = new int[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 };
for (var i = 0; i < 8; i++)
total += int.Parse(vatNumber[i].ToString()) *
Console.WriteLine("Total before modulus 11: " + total);
Console.WriteLine("Total after modulus 11: " + total);
Console.WriteLine("Comparing total " + total + " with last digit " + vatNumber.Substring(8));
if (total == int.Parse(vatNumber.Substring(8)))