此正则表达式是否失败,或者我是否需要修改正则表达式以支持 "optional followed by"?

Does this regex fail, or do I need to modify the regex to support "optional followed by"?

我正在尝试以下正则表达式:https://regex101.com/r/5dlRZV/1/,我知道,我正在尝试使用 \author 而不是 \maketitle

在 python 中,我尝试了以下操作:

import re

text = str(r'
\author{
\small 
}

\maketitle
')

regex = [re.compile(r'[\]author*|[{]((?:[^{}]*|[{][^{}]*[}])*)[}]', re.M | re.S), 
re.compile(r'[\]maketitle*|[{]((?:[^{}]*|[{][^{}]*[}])*)[}]', re.M | re.S)]

for p in regex: 
  for m in p.finditer(text): 
     print(m.group())

Python 冻结,我怀疑这与我的模式有关,SRE 失败。

编辑: 我的正则表达式有问题吗?可以改进到实际工作吗?我仍然在我的机器上得到相同的结果。

EDIT 2: 能否以某种方式修复此问题,以便模式支持 optional 后跟 ?: 或 ?= look-heads?这样一个人就可以同时捕获两者?

阅读标题 "Parentheses Create Numbered Capturing Groups" 后,在这个网站上:https://www.regular-expressions.info/brackets.html,我设法找到了答案:

Besides grouping part of a regular expression together, parentheses also create a 
numbered capturing group. It stores the part of the string matched by the part of 
the regular expression inside the parentheses.

The regex Set(Value)? matches Set or SetValue. 
In the first case, the first (and only) capturing group remains empty. 
In the second case, the first capturing group matches Value.