Skip to content

Instantly share code, notes, and snippets.

@zguangyu
Created October 5, 2014 12:13
Show Gist options
  • Save zguangyu/e949e576fd53378dec16 to your computer and use it in GitHub Desktop.
Save zguangyu/e949e576fd53378dec16 to your computer and use it in GitHub Desktop.
import re
import json
ori = '[1-5,8]'
m = re.search(r'([0-9]+)-([0-9]+)', s)
s = ''
for i in range((m.groups()[0]), (m.groups()[1])+1):
s += str(i)+','
l = re.sub(r'[0-9]+-[0-9]+,', s, '[1-5,8]')
out = json.loads(l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment