def _split_regex(regex):
if regex[<NUM_LIT:0>] == '<STR_LIT>':<EOL><INDENT>regex = regex[<NUM_LIT:1>:]<EOL><DEDENT>if regex[-<NUM_LIT:1>] == '<STR_LIT:$>':<EOL><INDENT>regex = regex[<NUM_LIT:0>:-<NUM_LIT:1>]<EOL><DEDENT>results = []<EOL>line = '<STR_LIT>'<EOL>for c in regex:<EOL><INDENT>if c == '<STR_LIT:(>':<EOL><INDENT>results.append(line)<EOL>line = '<STR_LIT>'<EOL><DEDENT>elif c == '<STR_LIT:)>':<EOL><INDENT>line = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>line = line + c<EOL><DEDENT><DEDENT>if len(line) > <NUM_LIT:0>:<EOL><INDENT>results.append(line)<EOL><DEDENT>return results<EOL>
Return an array of the URL split at each regex match like (?P<id>[\d]+)
Call with a regex of '^/foo/(?P<id>[\d]+)/bar/$' and you will receive ['/foo/', '/bar/']