Setting: A function generates a string containing a regular expression. The string must be used in two fashions: 1) It is printed into a file which contains python code to be later executed. 2) It must be used immediately as a regexp. For (1) backslashes must be escaped themselves several times, e.g. space1 = "\\\\s" # space now contains two backslashes print "space2 = '"+space1+"'" The resulting text contains then space2 = '\\s' # (*) and consequently variable space2 will contain just one backslash. Question: Given that I have space1, is there a function which does the same translation as does the python interpreter when interpreting/compiling the line (*) such that in this case I end up with just one backslash? Problem: Working with raw strings is currently not an option. Thanks, Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION bioscience | +49 6221 4038 172 | -- Paul Erdös *** Please do not send me copies of your posts. ***
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4