Skip to content

Instantly share code, notes, and snippets.

@barik
Created December 7, 2012 21:36
Show Gist options
  • Save barik/4236736 to your computer and use it in GitHub Desktop.
Save barik/4236736 to your computer and use it in GitHub Desktop.
break message
message = "ABC[DE]F[GH]I"
def breakmessage(message):
brace = False
out = []
for s in message:
if s == "[":
brace = True
t = ""
elif s == "]":
brace = False
out.append(t)
elif brace:
t += s
else:
out.append(s)
return out
print breakmessage(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment