>>> pattern = re.compile(r'(.*)\\\\(.*)\\\\(.*)')
>>> m = re.match(pattern, 'string1\string2\string3')
>>> m
>>>
>>> m.groups
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'groups'
上記の正規表現で次の形式の文字列を一致させようとしています: string1\string2\string3
.
上記は Python の出力です。適切な正規表現オブジェクトを返さないのはなぜですか? 私のパターンに何か問題がありますか?