my $xpath = 'BoringNode[1]/InterestingNode[@InterestingAttribute="outgrabe"]/AnotherBoringNode[@BoringAttribute="grey"]'; $xpath =~ /(InterestingNode\[.*?\])/; $1 =~ /"(.*)"/; print $1 . "\n"; #### $xpath =~ /(InterestingNode\[@.*?"(.*?)".*?\])/; print $2 . "\n";