You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
echo '123' | pyp "p.replace(p.re('BLAH'), '_')"
echo '123' | pyp "p.replace(p.re('[123]'), 'x')"
What is the expected output? What do you see instead?
EXPECTED:
123
xxx
GOT:
_1_2_3_
x23
What version of the product are you using? On what operating system?
2.12, Linux - Fedora 19 (Python 2.7)
Please provide any additional information below.
I tried the above because the docs specifically say: "works great with
p.replace(p.re(REGEX),STR)". However, as the above examples indicates, it can
lead to some unexpected results. However, since you wish to preserve the
"normal" behavior of p.re, I propose a new / separate method for doing regexp
based search-replace, ie, something like:
p.re_replace
or
p.re_sub
...which would simply wrap re.sub
Original issue reported on code.google.com by [email protected] on 21 Jan 2014 at 6:42
The text was updated successfully, but these errors were encountered:
Adding a patch to add the proposed rereplace... with it, if you run:
echo '123' | pyp "p.rereplace('BLAH', '_')"
echo '123' | pyp "p.rereplace('[123]', 'x')"
...you get the "EXPECTED" results given above...
Original issue reported on code.google.com by
[email protected]
on 21 Jan 2014 at 6:42The text was updated successfully, but these errors were encountered: