Regular expressions and EU VAT IDs

Posted: (EET/GMT+2)

 

The .NET Framework contains good support for regular expressions, but unfortunately a primer on how to create regular expressions is missing. As I'm no fan of Perl, I haven't had to learn the Regex syntax inside-out.

Now, I happened to browse the community workspaces of GotDotNet and from there I found an utility called RegexDesigner .NET from Sells Brothers.

This utility is a handy testbed for your .NET regular expressions, and the utility itself is cleanly written.

For example, I've lately needed to write a regex for testing EU VAT numbers for validity, and with the help of this utility, I found out (by trial and error) that the following regex seems to properly validate both Finnish and international formats:

(^[0-9]{7}-[0-9]|^\w{2}[0-9]{8})

Also, while playing with the EU VAT IDs, I found a site that allows you to really validate the numbers, and also displays the company name behind the number. The site is here.

Interesting.