Variables from a regex if /\A(?<first>\w+),\s*(?<last>\w+)\z/ =~ "Franze, Jr" puts "#{first} #{last}" end # Result: # Franze Jr View Source