Sujet : Re: Correct syntax for pathological re.search()
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.pythonDate : 08. Oct 2024, 21:57:45
Autres entêtes
Organisation : Stefan Ram
Message-ID : <repr-20241008205700@ram.dialup.fu-berlin.de>
References : 1 2 3 4
ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
"\\chardef \\\\ = '\\\\".
However, one can rewrite this as follows:
"`chardef `` = '``".replace( "`", "\"*4 )
. One can also use "repr" to find how to represent something:
main.py
text = input( "What do you want me to represent as a literal? " )
print( repr( text ))
transcript
What do you want me to represent as a literal? \sout\{
'\\sout\{'
. We can use "escape" and "repr" to find how to represent
a regular expression for a literal text:
main.py
import re
text = input( "Want the literal of an re for what text? " )
print( repr( re.escape( text )))
transcript
Want the literal of an re for what text? \sout{
'\\sout\{'
.