From: Stefan Monnier <monnier@iro.umontreal.ca>
To: rms@gnu.org
Cc: emacs-devel@gnu.org
Subject: Re: Explicitly numbered subgroups in regular expressions
Date: Sun, 10 Jun 2007 09:44:13 -0400 [thread overview]
Message-ID: <jwvlkes6i4y.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <E1HxNJs-0005hQ-0i@fencepost.gnu.org> (Richard Stallman's message of "Sun\, 10 Jun 2007 09\:19\:00 -0400")
> What it does is add a new regexp syntax \(?<num>:<regexp>\) which is
> like \(<regexp>\) except that it specifies explicitly the number of
> the subgroup. E.g. (and (string-match "\\(?3:a\\)" "a") (match-data))
> returns (0 1 nil nil nil nil 0 1). There is no backward compatibility
> issue with this patch: such regexps are currently rejected as invalid.
> The feature seems useful, but how does this affect the numbering of
> groups that don't specify a number?
A subgroup that doesn't explicitly specify a number gets the "smallest
natural number larger than all previous ones". I.e.
(and (string-match "\\(?3:a\\)\\(b\\)" "ab") (match-data))
returns
(0 2 nil nil nil nil 0 1 1 2)
since the second group gets number 4.
> That has to be done right, then documented in the two manuals.
Sure,
Stefan
next prev parent reply other threads:[~2007-06-10 13:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-09 20:37 Explicitly numbered subgroups in regular expressions Stefan Monnier
2007-06-10 13:19 ` Richard Stallman
2007-06-10 13:44 ` Stefan Monnier [this message]
2007-06-11 9:44 ` Richard Stallman
2007-06-12 18:42 ` Stefan Monnier
2007-06-12 20:56 ` Juri Linkov
2007-06-13 16:23 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvlkes6i4y.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.