my $fail = qr/^ # Start looking at the begining of the string (?! # and immediately fail if you find 7000$ # "7000" then the end of the string # (ie. the whole string = "7000") | 7777$ # or "7777" | 7778$ # etc. | 3886200$ | 2200$ | 8488$ | 3406$ | 9100$ | 29389988$ | 7688$ | 5000$ | 20$ | 3408$ | 3404$ | 7648$ ) # If you got this far with failing (ie. matching the enclosed. \d+$ # then match if the whole string consists of digits. /x #### my $fail = qr/^(?!(?:7000|7777|7778|3886200|2200|8488|3406|9100|29389988|7688|5000|20|3408|3404|7648)$)\d+$/;