if ( $string =~ m/${re1}/ or $string =~ m/${re2}/ ) { if ( length($1) and length($2) ) { } }