in reply to regular expression
Also consider packages such as Regexp::Common::CC, and others in that very large family of tools. A search for “credit card” at http://search.cpan.org produces 144 promising-sounding hits. If what you are trying to achieve is, as I suspect, “a properly anonymized credit card number,” there is basically a 100% chance that somebody else has already done that.   You can often save a tremendous amount of time by searching CPAN first and frequently, finding off-the-shelf solutions (both large and small) that are both thoroughly tested and comprehensively complete.