Refactor out hostname to RegExp generation