trim tag after substr

this prevents spaces in the middle of the tag from being added to the db