pattern = re.compile(r'''Hello''', re.M) match = pattern.match('Hello World!') if match: return match.group(1) return None