From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: jpkotta Newsgroups: gmane.emacs.help Subject: Re: Anchoring a RE in a string Date: Fri, 8 Jun 2012 12:18:45 -0700 (PDT) Message-ID: <16e6a48b-6b6c-46dd-b686-7a1a6dd944d6@googlegroups.com> References: <155DEC68569B714B86C2C7075F5EDA9802FEF67C@DAKIYA1.pegasus.local> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1339183143 16297 80.91.229.3 (8 Jun 2012 19:19:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 8 Jun 2012 19:19:03 +0000 (UTC) Cc: "help-gnu-emacs@gnu.org" To: gnu.emacs.help@googlegroups.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jun 08 21:19:01 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Sd4i1-00063o-02 for geh-help-gnu-emacs@m.gmane.org; Fri, 08 Jun 2012 21:18:57 +0200 Original-Received: from localhost ([::1]:50557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sd4i0-0007zv-PY for geh-help-gnu-emacs@m.gmane.org; Fri, 08 Jun 2012 15:18:56 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:35757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sd4hv-0007zm-51 for help-gnu-emacs@gnu.org; Fri, 08 Jun 2012 15:18:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sd4ht-0006jm-7C for help-gnu-emacs@gnu.org; Fri, 08 Jun 2012 15:18:50 -0400 Original-Received: from mail-ob0-f189.google.com ([209.85.214.189]:49938) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sd4ht-0006go-1n for help-gnu-emacs@gnu.org; Fri, 08 Jun 2012 15:18:49 -0400 Original-Received: by obbtb18 with SMTP id tb18so5776506obb.6 for ; Fri, 08 Jun 2012 12:18:46 -0700 (PDT) Original-Received: by 10.68.224.41 with SMTP id qz9mr447367pbc.0.1339183125961; Fri, 08 Jun 2012 12:18:45 -0700 (PDT) Original-Path: glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=70.97.12.233; posting-account=EwI0QQoAAADdqmqX_mVfawBNtwyks2YE Original-NNTP-Posting-Host: 70.97.12.233 User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 70.97.12.233 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.189 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:85169 Archived-At: On Friday, June 8, 2012 2:08:24 PM UTC-5, Doug Lewan wrote: > I've found the /adequate/ solution. > > (setq s (delete ?\n s)) > (string-match "^\\s-+ABCD" s) > > Still, is there no way of truly anchoring at the beginning of a string? > > > -----Original Message----- > > From: help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org > > [mailto:help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org] On > > Behalf Of Doug Lewan > > Sent: Friday, 2012 June 08 14:49 > > To: help-gnu-emacs@gnu.org > > Subject: Anchoring a RE in a string > > > > Currently I'm trying to check the /beginning/ of a multi-line string > > with a regular expression. > > The scenario looks like this: > > > > (string-match "^\\s-+ABCD" > > "qwer\n zxcv\n ABCD") > > ^ Matches here. > > > > I want it to fail because the beginning doesn't match. > > I hadn't expected the anchor (^) to match inside the string. > > > > I can't be the only one to have wanted to do this. > > What's the right way. > > > > Thanks. > > > > ,Douglas > > Douglas Lewan > > Shubert Ticketing > > (201) 489-8600 ext 224 > > > > Use \\` instead of ^. See "34.3.1.1 Special Characters in Regular Expressions" in the Elisp manual.