Here again you can leverage Enumerable;

    regexes = [ /^Name = \"(.*)\"\;$/, /^Name = (.*)\;$/ ]
    data.lines.select{ |line| if regexes.any?{ |r| line =~ r } then $1 end }.compact.uniq.map(&:strip)