明確にするために正規表現を複数の行に分割したいのですが、生の文字列を使用するのが最善の方法かわかりません。
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 を付ける必要がありますか?