Skip to content

Instantly share code, notes, and snippets.

@wardi
Created November 17, 2012 17:41
Embed
What would you like to do?
splitting on | with escaped \|'s and escaped \\'s
def split_bars(v):
i = iter(v.split('|'))
while True:
part = next(i)
while part.endswith('\\'):
part = part[:-1] + '|' + next(i)
yield part.replace('\\\\', '\\')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment