in reply to Quick regex
print $1 if "ab _ cd _ ef _ gh " =~ /(.*?(_).*?\2.*?)\2/; __END__ ab _ cd _ ef [download]