import re
texts = ['config.hello.world','config.hello','config.hello','config.hello.world']
rx = re.compile(r'\bconfig\.([\w.]+)(?![(\w])')
for text in texts:
	m = rx.search(text)
	if m:
		print(text + " => " + m.group(1))
	else:
		print(text + " => NO MATCH")