Try
Code:
categories_collapsed_name_template = r'{first.sort:re((.*?)(\,|$).*,\1)} - {last.sort:re((.*?)(\,|$).*,\1)}'
Beyond the re itself, the trick here (one that I had forgotten about) is the "r" in front of the quote. That tells python to not process any of the backslashes in the string. Without the r, the backslashed characters get converted to something else.
I think I will change the tweak so that the 'r' is there by default.