3
명확성을 위해 정규식을 여러 줄로 나누고 싶지만 원시 문자열을 사용하는 것이 가장 좋은 방법인지 모르겠습니다.파이썬의 원시 문자열에 암시 적 라인 조인에 필요한 내용
SECT_EXP = (
r'^(?P<number>.+?[.]? {1,2}' # Begin number pattern match
r'(?P<sect_num>' # Begin section number match
r'(?P<full_num>' # Begin full number match
r'(?P<title>\d{1,2}?)' # Match title substring
r'(?P<chapter>\d{2})' # Match chapter substring
r')' # End full number match
r'[.]'
r'(?P<section>\d+)' # Match section substring
r')' # End section number match
r')' # End number pattern match
r'([.]?)[ ]*$' # Lazy matching end of strings
)
그러나 암시 적 라인 결합을 사용할 때 전체 문자열이 원시 문자열로 처리되도록하려면 각 문자열 앞에 r을 붙여야합니까? this 페이지에서