The May 2016 Perl programming challenge by Tony Gasparovic


THE CHALLENGE: This months challenge is to create, test and validate a complex regular expression. DETAILS: The data file link below contains all the test cases you will need to validate your regular expression. You will need to write your own process to test and validate your regular expression. test cases Regular Expression Rules ______________________________________________________________________________________________________ Must be 20 charactors in length Must contain at least one lower case letter [a-z] Must contain at least two upper case letters [A-Z] 0 can only occur in odd positions. 1,3,5,7,9,11,13,15,17,19 1 can only occur in postions 5,6,7,8,9,10 2 can only occur in prime number positions 2,3,5,7,11,13,17,19 3 can not appear at start or the end 4 can not occur more than 3 times 5 can only appear in position 2,3,4,5 6 can only occur in even positions 2,4,6,8,10,12,14,16,18,20 7 & 8 can not occur together in any seqence 78,87 9 can only occur in positions 10,11,12,13,14,15,16,17,18,19,20 You get 100 points if you can solve it using one single regular expression /my-reg-ex/ You get 10 points if you solve it using more than one regular expression /my-reg-ex/ /my-reg-ex/ etc...... ANSWER: If your regular expression is correct your test results should show: 400000 good test cases 60000000 bad test cases
Regular Expression: my $regex='^(?=.*[a-z])(?=.*[A-Z].*[A-Z])(?=^(.[^0])+$)(?=^[^1]{4}.{6}[^1]+$)(?!(.*4){4})(?=^([^6].)+$)(?!.*78|.*87)(?=[^3].{18}[^3]$)(?=^[^9]{9}.{11}$)(?=^[^5].{4}[^5]+$)(?=[^2]..[^2].[^2].[^2][^2][^2].[^2].[^2][^2][^2].[^2].[^2])';