all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: why is this regexp invalid: "\\(?1:\\)"
Date: Fri, 03 Sep 2010 09:01:04 +0200	[thread overview]
Message-ID: <87aanzcnv3.fsf@lola.goethe.zz> (raw)
In-Reply-To: 87eidbgavq.fsf@kuiper.lan.informatimago.com

pjb@informatimago.com (Pascal J. Bourguignon) writes:

> Joel James Adamson <adamsonj@email.unc.edu> writes:
>
>> Ilya Shlyakhter <ilya_shl@alum.mit.edu> writes:
>>
>>> (string-match "\\(?1:\\)" "")
>>> (string-match "\\(?:\\)" "")
>>
>> I get 0 from both.
>
> Which is expected.  These regexps are not invalid, they're perfectly
> valid, and match perfectly what they have to match.
>
> Read (info "(elisp)Regexp Backslash").
>
> Notice that the two regexps have a different meaning.
>
> "\\(?1:\\)" matches exactly 0 characters, and assign them the group number 1.
>
> "\\(?:\\)" matches exactly 0 characters, if it can (it's shy), and
> assign them the next group number (which is 1 since it's the first
> group).

I recommend you check again what a shy group is supposed to be.

> In both case, when matching the empty string, the result should be 0,
> since there are 0 character at the position 0 in the empty string.

That much is correct.

-- 
David Kastrup


  reply	other threads:[~2010-09-03  7:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-01 19:40 why is this regexp invalid: "\\(?1:\\)" Ilya Shlyakhter
2010-09-02 18:27 ` Joel James Adamson
     [not found] ` <mailman.0.1283452083.4022.help-gnu-emacs@gnu.org>
2010-09-02 20:15   ` Pascal J. Bourguignon
2010-09-03  7:01     ` David Kastrup [this message]
2010-09-03 11:51       ` Pascal J. Bourguignon
     [not found] <mailman.2.1283370006.27482.help-gnu-emacs@gnu.org>
2010-09-02  8:17 ` Stefan Monnier

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=87aanzcnv3.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    --cc=help-gnu-emacs@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.