I need to extract strings from nested brackets like so: Result (Order doesn’t matter): Note, the string could have N brackets, and they will always be valid, but may or may not be nested. Also, the string doesn’t have to start with a bracket. The solutions I have found online to a similar problem suggest a regex, but I’m not
Tag: brackets
Get the string within brackets in Python
I have a sample string <alpha.Customer[cus_Y4o9qMEZAugtnW] active_card=<alpha.AlphaObject[card] …>, created=1324336085, description=’Customer for My Test App’, livemode=False> I only want the value cus_Y4o9qMEZAugtnW and NOT card (which is inside another []) How could I do it in easiest possible way in Python? Maybe by using RegEx (which I am not good at)? Answer How about: For me this prints: Note that the