You could simply split by the title tag like this:
title = result.split(//,2)[1].split(/<\/title>/,2)[0]
(edit: the second parameter to split works different than I am used to from python and doesn't count the number of splits but the number of elements in the result array, meaning split(/pattern/, 1)
actually doesn't split anything...)