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

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

Re: string-match bug?


From: Juanma Barranquero
Subject: Re: string-match bug?
Date: Tue, 8 Dec 2009 12:35:34 +0100

On Tue, Dec 8, 2009 at 11:42, Andreas Röhler
<address@hidden> wrote:

> Well, string-match should tell first point of occurrence if any.

This is exactly what it does.

> If we have none, as with slightly changed example
>
> (string-match "xyzzy" "foox-a-yzzybar")
> it duly returns "nil"  - and not "0" saying falsly "first point of 
> non-occurence"

It returns nil, i.e.: there's no point in the target string at which
the regexp matches.

> (string-match "" "fooxyzzybar") asks, if there is an empty string in string.
> If yes, report the starting point of the empty string.
>
> Does string start with an empty string? IMHO not.

It returns 0, i.e.: this is the point at which the target string
matches ("" will match at the beginning of every string).

It's entirely consistent. You want string-match to answer different
questions in your first and second examples.

    Juanma




reply via email to

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