No reason to not do the regex in Ruby, and relying on head and sed makes this a no-go on Windows.