Refactored extraction of various components of html string