]> git.eshelyaron.com Git - emacs.git/commitdiff
Clarify Fmatch_data doc string
authorLars Ingebrigtsen <larsi@gnus.org>
Sat, 29 Jan 2022 15:39:48 +0000 (16:39 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 29 Jan 2022 15:39:48 +0000 (16:39 +0100)
* src/search.c (Fmatch_data): Note quirk about non-matching
optional groups in the doc string (bug#29343).

src/search.c

index a1adfa2d8ce24a94ea339391f98047a237db68e5..80541921de13472fb158769cbb02225faa63061e 100644 (file)
@@ -2827,6 +2827,14 @@ All the elements are markers or nil (nil if the Nth pair didn't match)
 if the last match was on a buffer; integers or nil if a string was matched.
 Use `set-match-data' to reinstate the data in this list.
 
+Note that non-matching optional groups at the end of the regexp are
+elided instead of being represented with two `nil's each.  For instance:
+
+  (progn
+    (string-match "^\\(a\\)?\\(b\\)\\(c\\)?$" "b")
+    (match-data))
+  => (0 1 nil nil 0 1)
+
 If INTEGERS (the optional first argument) is non-nil, always use
 integers (rather than markers) to represent buffer positions.  In
 this case, and if the last match was in a buffer, the buffer will get