The following message is a courtesy copy of an article
that has been posted to comp.emacs.xemacs as well.
>>>> "APA" == Adrian Aichner
<adrian(a)xemacs.org> writes:
Hello George,
taking a closer look I think you found a bug in XEmacs.
Here is an enhanced test-case with my results included.
Testers: Just keep on eval-last-sexp to insert your results on various
platforms.
(progn
(setq reg1 "a\\(b\\(c\\)d\\|bc\\)"
reg2 "a\\(\\(bc\\)d\\|bc\\)")
(save-excursion
(re-search-forward reg1)
(goto-char (point-max))
(insert ";" (emacs-version) "\n")
(insert (format ";reg1\\1:%s\n" (match-string 1)))
(insert (format ";reg1\\2:%s\n" (match-string 2))))
(save-excursion
(re-search-forward reg2)
(goto-char (point-max))
(insert (format ";reg2\\1:%s\n" (match-string 1)))
(insert (format ";reg2\\2:%s\n" (match-string 2)))))
abc
;XEmacs 21.1 (patch 14) "Cuyahoga Valley" [Lucid] (i386-pc-win32) of Wed Mar 14
2001 on D5DC120J
;reg1\1:bc
;reg1\2:c
;reg2\1:bc
;reg2\2:nil
;XEmacs 21.4 (beta1) "Copyleft" [Lucid] (i586-pc-win32) of Tue Apr 24 2001 on
D5DC120J
;reg1\1:bc
;reg1\2:c
;reg2\1:bc
;reg2\2:nil
Best regards,
Adrian
>>>> "George" == George Ogata
<g_ogata(a)ihug.com.au> writes:
George> I have this in a buffer (XEmacs
21.1.14):
George> ---------- Buffer: foo ----------
George> (save-excursion
George> (setq reg1 "a\\(b\\(c\\)d\\|bc\\)"
George> reg2 "a\\(\\(bc\\)d\\|bc\\)")
George> (re-search-forward reg1)
George> (match-string 2))-!-
George> abc
George> ---------- Buffer: foo ----------
George> If I eval-last-sexp, it returns "c", but if I use reg2
George> instead of reg1, it returns nil. Is this how it should
George> be? The left side of \| wasn't used in either match, was
George> it? And so (match-string 2) should be nil for both?
APA> Hi George,
APA> to determine the matching subexpression, you have to count the number
APA> of \( from the left, starting at one, match-string 0 returns the whole
APA> match.
APA> So, the \| is not what's relevant here, it just specifies an
APA> alternative match inside the same subexpression.
APA> Hope this helps,
APA> Adrian
APA> --
APA> Adrian Aichner
APA> mailto:adrian@xemacs.org
APA>
http://www.xemacs.org/
--
Adrian Aichner
mailto:adrian@xemacs.org
http://www.xemacs.org/