Regexp::Common::VATIN - Patterns for matching EU VAT Identification Numbers
use feature qw(say); use Regexp::Common qw(VATIN); say "DE123456789" =~ $RE{VATIN}{DE}; # 1 say "DE123456789" =~ $RE{VATIN}{any}; # 1 say "LT123ABC" =~ $RE{VATIN}{LT}; # ""
This module provides regular expression patterns to match any of the sanctioned VATIN formats from the 27 nations levying a European Union value added tax. The data found at http://ec.europa.eu/taxation_customs/vies/faq.html#item_11 is used as the authoritative source of all patterns.
All patterns in this module are written to be compatible with JavaScript's somewhat less-expressive regular expression standard. They can thus easily be exported for use in a browser-facing web application:
use JSON qw(encode_json); my $patterns = encode_json($RE{VATIN});
In keeping with the standard set by the core Regexp::Common modules, patterns are neither anchored nor enclosed with word boundaries. Consider a malformed VATIN, e.g.,
my $vatin = "GB1234567890";
According to the sanctioned patterns from the United Kingdom, the above VATIN is malformed (one digit too many). And yet,
say $vatin =~ $RE{VATIN}{GB}; # 1
To test for an exact match, use start and end anchors:
say $vatin =~ /^$RE{VATIN}{GB}$/; # ""
For documentation of the interface this set of regular expressions uses.
Checks the official EU database for registered VATINs.
Richard Simões <rsimoes AT cpan DOT org>
<rsimoes AT cpan DOT org>
Copyright © 2013 Richard Simões. This module is released under the terms of the MIT License and may be modified and/or redistributed under the same or any compatible license.
To install Regexp::Common::VATIN, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Regexp::Common::VATIN
CPAN shell
perl -MCPAN -e shell install Regexp::Common::VATIN
For more information on module installation, please visit the detailed CPAN module installation guide.