(pattern, repl_async_fn, string)
| 68 | invocation_context = readonly_context._invocation_context |
| 69 | |
| 70 | async def _async_sub(pattern, repl_async_fn, string) -> str: |
| 71 | result = [] |
| 72 | last_end = 0 |
| 73 | for match in re.finditer(pattern, string): |
| 74 | result.append(string[last_end : match.start()]) |
| 75 | replacement = await repl_async_fn(match) |
| 76 | result.append(replacement) |
| 77 | last_end = match.end() |
| 78 | result.append(string[last_end:]) |
| 79 | return ''.join(result) |
| 80 | |
| 81 | async def _replace_match(match) -> str: |
| 82 | var_name = match.group().lstrip('{').rstrip('}').strip() |
no test coverage detected