def mark_begin_end_regex(regex, text, split_locations):
for match in regex.finditer(text):<EOL><INDENT>end_match = match.end()<EOL>begin_match = match.start()<EOL>for i in range(begin_match+<NUM_LIT:1>, end_match):<EOL><INDENT>split_locations[i] = SHOULD_NOT_SPLIT<EOL><DEDENT>if end_match < len(split_locations):<EOL><INDENT>if split_locations[end_match] == UNDECIDED:<EOL><INDENT>split_locations[end_match] = SHOULD_SPLIT<EOL><DEDENT><DEDENT>if split_locations[begin_match] == UNDECIDED:<EOL><INDENT>split_locations[begin_match] = SHOULD_SPLIT<EOL><DEDENT><DEDENT>
Regex that adds a 'SHOULD_SPLIT' marker at the end
location of each matching group of the given regex,
and adds a 'SHOULD_SPLIT' at the beginning of the
matching group. Each character within the matching
group will be marked as 'SHOULD_NOT_SPLIT'.

Arguments
---------
    regex : re.Expression
    text : str, same length as split_locations
    split_locations : list<int>, split decisions.