if( $string =~ m[^a=<([^>]*)>] and $1 =~ m[$target] ) { # Do something }