$ emacs -Q -batch -eval '(progn (string-match "^\\(a\\)?\\(b\\)\\(=
c\\)?$" "b") (print (match-data)))'
(0 1 nil nil 0 1)
Note that neither the `a` nor the `c` group matched, but there are
entries for `a` in `match-data`, but not for `c`.=C2=A0 This makes working<=
br>
with the match data unnecessarily hard because its length depends on
whether certain optional groups have matched or not.=C2=A0 I haven't se=
en any
discussion about this behavior in either the manual or the docstring.=C2=A0=
I
think the match data in this case should be (0 1 nil nil 0 1 nil nil).
It turns out that this is harder than I ex=
pected, because the information about the number of groups in the pattern i=
sn't stored anywhere, and search_regs.num_regs may be different from th=
e group count. If it turns out too hard to fix, the behavior should at leas=
t be documented.