import re
subject = 'a1,a2,a3,a4,{_some_length_not_known_in_advance,a6}'
regex = re.compile(r'{[^}]*}|(,)')
# put Group 1 captures in a list
matches = [group for group in re.findall(regex, subject) if group]

# How many matches are there?
print("\n" + "*** Number of Matches ***")
print(len(matches))

# What are all the matches?
print("\n" + "*** Matches ***")
if len(matches)>0:
	for match in matches:
	    print (match)
		
# Replace the matches
def myreplacement(m):
    if m.group(1):
        return "SplitHere"
    else:
        return m.group(0)
replaced = regex.sub(myreplacement, subject)
print("\n" + "*** Replacements ***")
print(replaced)

# Split
# Start by replacing by something distinctive as above,
# then split.
splits = replaced.split('SplitHere')
print("\n" + "*** Splits ***")
for split in splits:
	    print (split)