import re def is_hmmmm(string): search = re.search("^hm{2,}(\.{3,}|)$", string) return search