I'm trying to determine whether a term appears in a string. Before and after the term must appear a space, and a standard suffix is also allowed. Example: term: google string: "I love google!!! " result: found term: dog string: "I love dogs " result: found I'm trying the following code: regexPart1 = "\s" regexPart2 = "(?:s|'s|!+|,|.|;|:|\(|\)|\"|\?+)?\s" p = re.compile(regexPart1 + term + regexPart2 , re.IGNORECASE) and get the error: raise error("multiple repeat") sre_constants.error: multiple repeat Update Real code that fails: term = 'lg incite" OR author:"http++www.dealitem.com" OR "for sale' regexPart1 = r"\s" regexPart2 = r"(?:s|'s|!+|,|.|;|:|\(|\)|\"|\?+)?\s" p = re.compile(regexPart1 + term + regexPart2 , re.IGNORECASE) On the other hand, the following term passes smoothly (+ instead of ++) term = 'lg incite" OR author:"http+www.dealitem.com" OR "for sale' Continue reading...