Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def row_repair(row_to_repair, base_row, regex_text_to_replace, regex_base_text):
- used_items = []
- start_index = 0
- while True:
- match_text = match_forward(regex=regex_text_to_replace, iterable=row_to_repair, start=start_index)
- if not match_text[0] or start_index >= len(base_row) - 1:
- break
- text_to_replace = match_text[0].group(1)
- for cell_i in range(start_index, len(base_row)):
- c_cell = base_row[cell_i]
- start_index = cell_i
- if c_cell in used_items:
- break
- if re.search(regex_base_text, c_cell, re.I | re.S):
- try:
- row_to_repair[cell_i] = text_to_replace
- used_items.append(c_cell)
- except IndexError:
- break
- used_items = []
- return row_to_repair
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement