diff options
author | Andrew Leech <andrew.leech@planetinnovation.com.au> | 2020-09-25 12:27:02 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-09-30 23:18:34 +1000 |
commit | 319437d4bd7c97ab18275d3eaf1bc190554f9df7 (patch) | |
tree | 93d6cf174d3286cbabb2266698887a621b156f26 /extmod/modure.c | |
parent | 0fd0eb00aa5b9d311046d48d73a8cfabb30d7dd6 (diff) |
extmod/modure: Allow \\ in re.sub replacements.
Diffstat (limited to 'extmod/modure.c')
-rw-r--r-- | extmod/modure.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/extmod/modure.c b/extmod/modure.c index 328c897d8..220587b42 100644 --- a/extmod/modure.c +++ b/extmod/modure.c @@ -343,6 +343,9 @@ STATIC mp_obj_t re_sub_helper(size_t n_args, const mp_obj_t *args) { const char *end_match = match->caps[match_no * 2 + 1]; vstr_add_strn(&vstr_return, start_match, end_match - start_match); } + } else if (*repl == '\\') { + // Add the \ character + vstr_add_byte(&vstr_return, *repl++); } } else { // Just add the current byte from the replacement string |