:param text_: string content :param args: like , , , , ... :return: if text_ length was zero or invalid parameters then no manipulation to text_
(text_, *args)
| 5 | |
| 6 | |
| 7 | def sequential_rep(text_, *args): |
| 8 | # type: (basestring, tuple) -> basestring |
| 9 | """ |
| 10 | :param text_: string content |
| 11 | :param args: like <pattern>, <replacement>, <pattern>, <replacement>, ... |
| 12 | :return: if text_ length was zero or invalid parameters then no manipulation to text_ |
| 13 | """ |
| 14 | arg_len = len(args) |
| 15 | if arg_len % 2 == 0 and isinstance(text_, str) and len(text_) > 0: |
| 16 | i = 0 |
| 17 | while i < arg_len: |
| 18 | text_ = re.sub(args[i], args[i + 1], text_) |
| 19 | i += 2 |
| 20 | |
| 21 | return text_ |
| 22 | |
| 23 | |
| 24 | def replace_ltgt(text_): |