Why does this work:
string = 'N{P}[ST]{P}'
>>> import re
>>> re.split(r"[\[\]]", string)
>>> ['N{P}', 'ST', '{P}']
But this don't?
>>> re.split(r"{\{\}}", string)
Why does this work:
string = 'N{P}[ST]{P}'
>>> import re
>>> re.split(r"[\[\]]", string)
>>> ['N{P}', 'ST', '{P}']
But this don't?
>>> re.split(r"{\{\}}", string)
You have to do this:
re.split(r"[{}]", string)
r"{\{\}}" is a special re syntax to repeat groups (ex: (ab){1,3} matches ab, abab or ababab) but not the character range (note that you don't have to escape the curly braces in a character range).
(I admit I don't know what your strange regex is supposed to do specially in the re.split context, but not what you want :))
{ and } are meta-characters in regular expressions and should be escaped or put into a character class
{\{\}} - means just escaped curly braces within unescaped