On 2022-05-17 16:21, Peter J. Holzer wrote:
On 2022-05-16 20:48:02 -0400, Dennis Lee Bieber wrote:
On Mon, 16 May 2022 17:22:17 -0700 (PDT), "hongy...@gmail.com"
<hongyi.z...@gmail.com> declaimed the following:
>a=re.sub(r"'","",a)
Explain what you believe this operation is doing, show us the input and
the output.
The best I can make out of that is that it is looking for single quote
characters within whatever "a" is, and replacing them with nothing.
Something much more understandable, without invoking a regular expression
library (especially when neither the search nor the replacement terms are
regular expressions) with simple string operations...
stripped = "".join(quoted.split("'"))
Whether that's easier to understand it very much in the eye of the
beholder.
As it's just a simple replacement, I would've thought that the 'obvious'
solution would be:
a = a.replace("'", "")
--
https://mail.python.org/mailman/listinfo/python-list