What does the “r” in pythons re.compile(r' pattern flags') mean?

前端 未结 3 704
慢半拍i
慢半拍i 2020-11-29 01:20

I am reading through http://docs.python.org/2/library/re.html. According to this the \"r\" in pythons re.compile(r\' pattern flags\') refers the raw string

3条回答
  •  感动是毒
    2020-11-29 02:08

    No. Not everything in regex syntax needs to be preceded by \, so ., *, +, etc still have special meaning in a pattern

    The r'' is often used as a convenience for regex that do need a lot of \ as it prevents the clutter of doubling up the \

提交回复
热议问题