Python Forum
python escaping character - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: python escaping character (/thread-42217.html)



python escaping character - atom509 - May-29-2024

Hi guys,

How can i escape the special character from this sql . it is store as string

SELECT REGEXP_SUBSTR(SYS_CONNECT_BY_PATH(nom, '\'), '[^\]+', 3, 4)


RE: python escaping character - DeaD_EyE - May-29-2024

SELECT REGEXP_SUBSTR(SYS_CONNECT_BY_PATH(nom, '\\'), r'[^\]+', 3, 4)
The first literal \ must be escaped with another \.

Using a raw string (sometimes called regex string) does not help, because after the backslash comes the quotation mark.

The second string literal can be written as raw string, because the quotation mark does not follow after the backslash.