From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: PJ Weisberg Newsgroups: gmane.emacs.help Subject: Re: error in replace-match: "args out of range" Date: Sat, 9 Apr 2011 13:04:59 -0700 Message-ID: References: <4D90D85C.5060805@mousecar.com> <4D98EE5B.4080108@mousecar.com> <87vcytd5dn.fsf@puma.rapttech.com.au> <87k4f5d4p6.fsf@puma.rapttech.com.au> <4D9FE70A.8010806@mousecar.com> <87hba7oa4c.fsf@fencepost.gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1302379855 12348 80.91.229.12 (9 Apr 2011 20:10:55 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 9 Apr 2011 20:10:55 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Apr 09 22:10:50 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q8eUb-0005FH-Py for geh-help-gnu-emacs@m.gmane.org; Sat, 09 Apr 2011 22:10:49 +0200 Original-Received: from localhost ([127.0.0.1]:47800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q8eUb-0006oR-7a for geh-help-gnu-emacs@m.gmane.org; Sat, 09 Apr 2011 16:10:49 -0400 Original-Received: from [140.186.70.92] (port=56655 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q8eUG-0006oL-7t for help-gnu-emacs@gnu.org; Sat, 09 Apr 2011 16:10:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q8eUF-0005W8-AR for help-gnu-emacs@gnu.org; Sat, 09 Apr 2011 16:10:28 -0400 Original-Received: from smtpauth03.prod.mesa1.secureserver.net ([64.202.165.183]:41589) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Q8eUF-0005W4-1W for help-gnu-emacs@gnu.org; Sat, 09 Apr 2011 16:10:27 -0400 Original-Received: (qmail 19915 invoked from network); 9 Apr 2011 20:10:24 -0000 Original-Received: from unknown (209.85.161.41) by smtpauth03.prod.mesa1.secureserver.net (64.202.165.183) with ESMTP; 09 Apr 2011 20:10:24 -0000 Original-Received: by fxm18 with SMTP id 18so3674713fxm.0 for ; Sat, 09 Apr 2011 13:10:22 -0700 (PDT) Original-Received: by 10.223.125.66 with SMTP id x2mr1125148far.51.1302379499284; Sat, 09 Apr 2011 13:04:59 -0700 (PDT) Original-Received: by 10.223.96.143 with HTTP; Sat, 9 Apr 2011 13:04:59 -0700 (PDT) In-Reply-To: <87hba7oa4c.fsf@fencepost.gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 64.202.165.183 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:80741 Archived-At: On 4/9/11, David Kastrup wrote: > ken writes: > >> On 04/09/2011 02:44 AM PJ Weisberg wrote: >>> On 4/8/11, ken wrote: >>>> On 04/07/2011 07:25 PM Tim X wrote: >>>>> This was my point of warning. It is quite possible to have >>>>> regexps where sub expressions are not found, but the overall regexp >>>>> succeeds. >>>> I'm having a hard time with that concept. Is there a small bit of >>>> example code you could show it with? >>> >>> "I am\\( not\\)? a fish." >>> >>> -PJ >> >> And on what sort of string would that RE match but the subexpression >> have the value nil (as opposed to the null string "")? > > Huh? Isn't that rather obvious? > > (list (string-match "I am\\( not\\)? a fish." "I am a fish!") > (match-string 1)) => (0 nil) Notice that the expression " not" can NEVER match an empty string. The ? allows it to appear zero times, so the overall expression matches even though the subexpression doesn't. -PJ