import re def rgx_sub(pattern, sub_text, source_text): return re.sub(pattern,sub_text,source_text) def rgx_search(pattern, source_text): matches = re.search(pattern,source_text) if matches: return matches.group() else: return []