def partition_raw_range(range): """takes a text range and breaks it up into its constituents: /foo/+10;$-15 ...would yield... left: /foo/ left_offset: +10 separator: ; right: $ right_offset: -15 """ parts = EX_RANGE_REGEXP.search(range).groups() # xxx try to make the regexp capture the desired groups only. return EX_RANGE( left=parts[1], left_offset=parts[3] or '0', separator=parts[5], right=parts[7], right_offset=parts[9] or '0' )
def test_full_cmd_regexp(): # assert EX_RANGE_REGEXP.search('/foo/').groups() == ('/foo') assert EX_RANGE_REGEXP.search("'<,'>cmd").groups() == ('/foo')