Created
January 7, 2014 18:46
-
-
Save DeeNewcum/8304425 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Regexp::Optimizer; | |
my @losers_minus_winners = qw[ | |
blaine breckinridge bryan cass clay cox davis dewey dole dukakis ford fremont | |
goldwater gore greeley hancock hughes humphrey kerry king landon mccain | |
mcclellan mcgovern mondale parker pinckney romney scott seymour smith stevenson | |
tilden wilkie | |
]; | |
# build the input regexp | |
my $re = '^!(' . join('|', @losers_minus_winners) . ')$'; | |
#die "$re\n"; | |
# do DFA optimization | |
$re = Regexp::Optimizer->new->as_string(qr/$re/); | |
# do some superficial changes for presentation purposes | |
$re =~ s/^\(\?\^://; | |
$re =~ s/\)$//; | |
$re =~ s/\(\?:/(/g; | |
print "$re\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The starting regexp is: