On 2024-10-19 00:15:23 +0200, jak via Python-list wrote: > Peter J. Holzer ha scritto: > > As a trivial example, the regular expressions r"\\sout{" and r"\\sout\{" > > are equivalent (the \ before the { is redundant). Yet > > re.compile(s).pattern preserves the difference between the two strings. > > Allow me to be fussy: r"\\sout{" and r"\\sout\{" are similar but not > equivalent.
They are. Both will match the 6 character string 0005c \ REVERSE SOLIDUS 00073 s LATIN SMALL LETTER S 0006f o LATIN SMALL LETTER O 00075 u LATIN SMALL LETTER U 00074 t LATIN SMALL LETTER T 0007b { LEFT CURLY BRACKET > If you omit the backslash, the parser will have to determine if the > graph is part of regular expression {n, m} and will take more time. Yes, that's the parser. But the result of parsing will be the same: The string will end in a literal backslash. hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | h...@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!"
signature.asc
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list