import re
r = r"These\s+are\s+my\s+variables((?:\s*-\w+\s+\$\w+)*)\s+for\s+(case\d)"
s = "These are my variables -abc $def -geh $ijk for case1"
m = re.search(r, s)
if m:
print(re.findall(r'-(\w+)', m.group(1)))
print(re.findall(r'\$(\w+)', m.group(1)))
print(m.group(2))
aW1wb3J0IHJlCnIgPSByIlRoZXNlXHMrYXJlXHMrbXlccyt2YXJpYWJsZXMoKD86XHMqLVx3K1xzK1wkXHcrKSopXHMrZm9yXHMrKGNhc2VcZCkiCnMgPSAiVGhlc2UgYXJlIG15IHZhcmlhYmxlcyAtYWJjICRkZWYgLWdlaCAkaWprIGZvciBjYXNlMSIKbSA9IHJlLnNlYXJjaChyLCBzKQppZiBtOgoJcHJpbnQocmUuZmluZGFsbChyJy0oXHcrKScsIG0uZ3JvdXAoMSkpKQoJcHJpbnQocmUuZmluZGFsbChyJ1wkKFx3KyknLCBtLmdyb3VwKDEpKSkKCXByaW50KG0uZ3JvdXAoMikp