def parse(): """Get code sample content and parse it.""" content = get_file(path) p = re.search(r'\[block:code](.*?)\[/block]', content, re.S) r = p.group(1) whole_sample_dict = json.loads(r) return whole_sample_dict # HOW COULD I HAVE A FUNCTION parse(regex) that takes in some regex as param