Modified ranking and regex to favor smaller, right-most strings

I have modified the regex to obtain short, overlapping matches to the search term. Also I have changed the scoring to favor search terms that are closer to the right of the path.