help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: error in replace-match: "args out of range"


From: Perry Smith
Subject: Re: error in replace-match: "args out of range"
Date: Sat, 9 Apr 2011 16:25:19 -0500

On Apr 9, 2011, at 3:04 PM, PJ Weisberg wrote:

> On 4/9/11, David Kastrup <dak@gnu.org> wrote:
>> ken <gebser@mousecar.com> writes:
>> 
>>> On 04/09/2011 02:44 AM PJ Weisberg wrote:
>>>> On 4/8/11, ken <gebser@mousecar.com> 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.

Also, "" does not match the subexpression.  I don't know but that may be key as 
well.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]