easy regexp by jonathan camacho

$_=join("",<>);
s/\[(.+?)\]/"(" . join("|", split(m||, $1)) . ")"/eg;
s/(^|\)|\?)(\w+)(?!\?)/$1($2)/g;
s/(\w+)\?/($1)\?/g;
s/\(([^\(\)]+)\)\?/(|$1)/g;
s/\(([^\(\)]+)\)/push(@e, [split(m!\|!, $1)])/eg;
@o = (""); for $aref (@e){ @n = (); for $lh (@o){
push @n, $lh . $_ for @$aref } @o = @n; }
print $_ . $/ for @o

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page