in reply to Quick regex

This is probably faq
print $1 if "ab _ cd _ ef _ gh " =~ /(.*?(_).*?\2.*?)\2/; __END__ ab _ cd _ ef