import re


def identify_var(varname,string,patterns=['equation','level','fixed','lower','upper']):
	"""
	Identify lists with patterns where the variable enters. 
	"""
	std_pattern =  {'equation': '[ \t(.*]{name}\[.*?\]', 
					'level': 	'[ \t(.*]{name}.l\[.*?\]',
					'fixed': 	'[ \t(.*]{name}.fx\[.*?\]',
					'lower': 	'[ \t(.*]{name}.lo\[.*?\]',
					'upper': 	'[ \t(.*]{name}.up\[.*?\]'}
	out = {pattern: [] for pattern in patterns}
	for x in std_pattern:
		if x in patterns:
			out[x] = re.findall(r'{pattern}'.format(pattern=std_pattern[x].format(name=varname)),string,flags=re.IGNORECASE)
	return out