From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.help Subject: Re: string-match bug? Date: Tue, 8 Dec 2009 12:35:34 +0100 Message-ID: References: <4b1d1a48$0$278$14726298@news.sunsite.dk> <4b1d1e3d$0$276$14726298@news.sunsite.dk> <4B1D6773.3000509@easy-emacs.de> <4B1E2DA8.3090907@easy-emacs.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1260272259 2061 80.91.229.12 (8 Dec 2009 11:37:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 8 Dec 2009 11:37:39 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: =?UTF-8?Q?Andreas_R=C3=B6hler?= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 08 12:37:29 2009 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.50) id 1NHyNk-0001PA-Ew for geh-help-gnu-emacs@m.gmane.org; Tue, 08 Dec 2009 12:37:28 +0100 Original-Received: from localhost ([127.0.0.1]:49681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHyNk-0005cE-6h for geh-help-gnu-emacs@m.gmane.org; Tue, 08 Dec 2009 06:37:28 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NHyMM-0004xz-24 for help-gnu-emacs@gnu.org; Tue, 08 Dec 2009 06:36:02 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NHyMF-0004so-W0 for help-gnu-emacs@gnu.org; Tue, 08 Dec 2009 06:36:00 -0500 Original-Received: from [199.232.76.173] (port=44426 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHyMF-0004sU-Ax for help-gnu-emacs@gnu.org; Tue, 08 Dec 2009 06:35:55 -0500 Original-Received: from mail-bw0-f215.google.com ([209.85.218.215]:53011) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NHyMF-0004T4-6n for help-gnu-emacs@gnu.org; Tue, 08 Dec 2009 06:35:55 -0500 Original-Received: by bwz7 with SMTP id 7so4771550bwz.26 for ; Tue, 08 Dec 2009 03:35:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=La+PN9BCtp1HcotihnY7HVkgb+EJBnF6RJKuYssoF1g=; b=HJ3BypGjWLn/jNkAuProLVJ22pQB9azC8D7PV0qXi7eTGSrIprJghH/qkXaerb8KZC BciO6DguBrlj6MNiY42l6h2b1n8YHWXQZJW5g2b1VFg6ZPLmMU171iMK+1k+NbkrgLfA 9wVNOEeYWQEhLGRt9T7GmbHExM2sO8OrTIa8o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=wDQ3ssVLoDSu9PVk2BHZL3lQEodkKnMI1XKegDHnXhiyiSzp0QYwSnwrstLGceZdfN 5PAiBW19N6HJr4smE+36aOwjKUzyp0FaoLZPtjr+UaqWhTn1DjjCi1TaaYDAh58JZUjc cRF+3GJWJSufCSDbLkDDJom6KbK8+s6njhqhA= Original-Received: by 10.204.29.22 with SMTP id o22mr437726bkc.78.1260272154129; Tue, 08 Dec 2009 03:35:54 -0800 (PST) In-Reply-To: <4B1E2DA8.3090907@easy-emacs.de> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:70498 Archived-At: On Tue, Dec 8, 2009 at 11:42, Andreas R=C3=B6hler 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" =C2=A0- and not "0" saying falsly "first point of n= on-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 stri= ng. > 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