| Server IP : 13.235.167.51 / Your IP : 216.73.217.116 Web Server : Apache System : Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64 User : root ( 0) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /usr/share/modsecurity-crs/util/regexp-assemble/ |
Upload File : |
#!/usr/bin/perl
#
# Create one regexp from a set of regexps.
# Regexps can be submitted via standard input, one per line.
#
# Requires Regexp::Assemble Perl module.
# To install: cpan install Regexp::Assemble
#
# See: https://coreruleset.org/20190826/optimizing-regular-expressions/
#
use strict;
use Regexp::Assemble;
my $ra = Regexp::Assemble->new;
while (<>)
{
# Handle possessive qualifiers
# https://rt.cpan.org/Public/Bug/Display.html?id=50228#txn-672717
my $arr = $ra->lexstr($_);
for (my $n = 0; $n < $#$arr - 1; ++$n)
{
if ($arr->[$n] =~ /\+$/ and $arr->[$n + 1] eq '+') {
$arr->[$n] .= splice(@$arr, $n + 1, 1);
}
}
$ra->insert(@$arr);
}
print $ra->as_string() . "\n";