Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Anchoring a RE in a string
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Doug Lewan  
View profile  
 More options Jun 8 2012, 2:48 pm
Newsgroups: gnu.emacs.help
From: Doug Lewan <do...@shubertticketing.com>
Date: Fri, 8 Jun 2012 18:48:52 +0000
Local: Fri, Jun 8 2012 2:48 pm
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Doug Lewan  
View profile  
 More options Jun 8 2012, 3:08 pm
Newsgroups: gnu.emacs.help
From: Doug Lewan <do...@shubertticketing.com>
Date: Fri, 8 Jun 2012 19:08:24 +0000
Local: Fri, Jun 8 2012 3:08 pm
Subject: RE: Anchoring a RE in a string
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?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jpkotta  
View profile  
 More options Jun 8 2012, 3:18 pm
Newsgroups: gnu.emacs.help
From: jpkotta <jpko...@gmail.com>
Date: Fri, 8 Jun 2012 12:18:45 -0700 (PDT)
Local: Fri, Jun 8 2012 3:18 pm
Subject: Re: Anchoring a RE in a string

Use \\` instead of ^.  See "34.3.1.1 Special Characters in Regular Expressions" in the Elisp manual.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jpkotta  
View profile  
 More options Jun 8 2012, 3:18 pm
Newsgroups: gnu.emacs.help
From: jpkotta <jpko...@gmail.com>
Date: Fri, 8 Jun 2012 12:18:45 -0700 (PDT)
Local: Fri, Jun 8 2012 3:18 pm
Subject: Re: Anchoring a RE in a string

Use \\` instead of ^.  See "34.3.1.1 Special Characters in Regular Expressions" in the Elisp manual.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Doug Lewan  
View profile  
 More options Jun 8 2012, 5:06 pm
Newsgroups: gnu.emacs.help
From: Doug Lewan <do...@shubertticketing.com>
Date: Fri, 8 Jun 2012 21:06:25 +0000
Local: Fri, Jun 8 2012 5:06 pm
Subject: RE: Anchoring a RE in a string
\` -- 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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Philipp Haselwarter  
View profile  
 More options Jun 9 2012, 3:28 pm
Newsgroups: gnu.emacs.help
From: Philipp Haselwarter <phil...@haselwarter.org>
Date: Sat, 09 Jun 2012 21:28:22 +0200
Local: Sat, Jun 9 2012 3:28 pm
Subject: Re: Anchoring a RE in a string
`rx' is cool when you're too lazy to look up special symbols

--
Philipp Haselwarter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
rusi  
View profile  
 More options Jun 10 2012, 1:38 am
Newsgroups: gnu.emacs.help
From: rusi <rustompm...@gmail.com>
Date: Sat, 9 Jun 2012 22:38:18 -0700 (PDT)
Local: Sun, Jun 10 2012 1:38 am
Subject: Re: Anchoring a RE in a string
On Jun 10, 12:28 am, Philipp Haselwarter <phil...@haselwarter.org>
wrote:

> `rx' is cool when you're too lazy to look up special symbols

> --
> Philipp Haselwarter

Interesting!! Cant find an info page.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Philipp Haselwarter  
View profile  
 More options Jun 10 2012, 3:06 am
Newsgroups: gnu.emacs.help
From: Philipp Haselwarter <phil...@haselwarter.org>
Date: Sun, 10 Jun 2012 09:06:16 +0200
Local: Sun, Jun 10 2012 3:06 am
Subject: Re: Anchoring a RE in a string

On Sun, Jun 10 2012 07:38 (@1339306698), rusi wrote:
> On Jun 10, 12:28 am, Philipp Haselwarter <phil...@haselwarter.org>
> wrote:
>> `rx' is cool when you're too lazy to look up special symbols

>> --
>> Philipp Haselwarter

> Interesting!! Cant find an info page.

Unfortunately, its only mention in emacs or elisp info is Gerd
Moellmann's authorship notice: "[...] `rx.el', a regular expression
constructor. ".

Take a look at C-h f rx RET

--
Philipp Haselwarter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Drew Adams  
View profile  
 More options Jun 10 2012, 10:34 am
Newsgroups: gnu.emacs.help
From: "Drew Adams" <drew.ad...@oracle.com>
Date: Sun, 10 Jun 2012 07:34:30 -0700
Local: Sun, Jun 10 2012 10:34 am
Subject: RE: Anchoring a RE in a string

> Unfortunately, its only mention in emacs or elisp info is Gerd
> Moellmann's authorship notice: "[...] `rx.el', a regular expression
> constructor. ".  Take a look at C-h f rx RET

If you cannot find something in the manuals, try searching for it at EmacsWiki
(or Google after that).  Entering "rx" in the wiki search field shows this page
as the first search hit: http://emacswiki.org/emacs/rx.

(That of course is not intended to mean that something should not also be
mentioned in the manuals.  It's just intended to help you find information.  The
wiki is another resource, like help-gnu-em...@gnu.org.)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »