Correct syntax for pathological re.search()
jak
nospam at please.ty
Fri Oct 18 18:15:23 EDT 2024
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.
Hi,
Allow me to be fussy: r"\\sout{" and r"\\sout\{" are similar but not
equivalent. 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. In some online regexs have these results:
r"\\sout{" : 1 match ( 7 steps, 620 μs )
r"\\sout\{" : 1 match ( 7 steps, 360 μs )
More information about the Python-list
mailing list