Python regex with question mark literal

前端 未结 5 1271
耶瑟儿~
耶瑟儿~ 2020-12-06 17:30

I\'m using Django\'s URLconf, the URL I will receive is /?code=authenticationcode
I want to match the URL using r\'^\\?code=(?P.*)$\'

5条回答
  •  囚心锁ツ
    2020-12-06 17:55

    "How to match the '?', is it special?" Yes, but you are properly escaping it by using the backslash. I do not see where you have accounted for the leading forward slash, though. That bit just needs to be added in:

    r'^/\?code=(?P.*)$'
    

提交回复
热议问题