/^(?=.*?$pat1)(?=.*?$pat2)/; # Sets $1 and $2. /^(?=.*?$pat1)(?=.*?$pat2)/; # Doesn't set $1 or $2.