$var =~ /(["'])[^(??{"$1"})]*?\1/; which worked unless $1 contained a special character (forgot the character, but it wasn't a quote),