Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Deny backslash using regex
#1
My backslash don't work ?
SyntaxError: EOL while scanning string literal

Exemple backslash :

v_char = "search?q=\"

o_rex = re.match(r"^(?!.*\).*$", v_char, re.IGNORECASE)

try:
    v_res = o_rex.string
    print("Security data . . .")

except(TypeError, AttributeError):
    print("Insecure data !")
Reply
#2
You have probably typed or copied that string yourself.
When it parsed or coming other placed from python it will be \\:
v_char = "search?q=\\"
This is because of escape character,so python read it as one \.
Will see this if use print().
>>> v_char = "search?q=\\"
>>> v_char 
'search?q=\\'
>>>
>>> print(v_char)
>>> search?q=\
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  change backslash into slash in a path paul18fr 7 2,334 Jul-21-2022, 04:26 PM
Last Post: deanhystad
  converting backslash codes Skaperen 4 5,436 Apr-21-2018, 04:07 AM
Last Post: Skaperen
  Reading and writing Windows filepath without treating backslash as escape character Dangthrimble 3 3,531 Dec-18-2017, 06:18 PM
Last Post: DeaD_EyE
  Replace Single Backslash with Double Backslash in python saswatidas437 2 33,289 Mar-19-2017, 10:48 AM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020