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

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

RE: Anchoring a RE in a string


From: Doug Lewan
Subject: RE: Anchoring a RE in a string
Date: Fri, 8 Jun 2012 21:06:25 +0000

\` -- empty string at the beginning of buffer

Fantastic!

In fact, I'd found my first use for \' just recently. I don't know why it 
didn't strike me.

I will never run out of things to learn in emacs. As a video game, I still feel 
like I'm on level 2.

> -----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 jpkotta
> Sent: Friday, 2012 June 08 15:19
> To: gnu.emacs.help@googlegroups.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Anchoring a RE in a string
> 
> 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.




reply via email to

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