Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.emacs > #1619

Re: Quickie - Regexp for a string not at the beginning of the line

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Axel Wegen <axel.wegen@gmail.com>
Newsgroups comp.emacs
Subject Re: Quickie - Regexp for a string not at the beginning of the line
Date Tue, 06 Nov 2012 17:39:09 +0100
Organization solani.org
Lines 27
Message-ID <87a9uun0sy.fsf@gmail.com> (permalink)
References <9eba5652-f814-41fa-83e4-460bca2be264@n16g2000yqi.googlegroups.com> <e6f60702-d85f-4aed-bc03-3147bb007ad8@googlegroups.com> <73f60cf3-d932-4366-a405-6767488560c6@q16g2000yqc.googlegroups.com> <ec1dadee-be52-4a5f-9ccf-966ffb6a92a7@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain
X-Trace solani.org 1352219952 21840 eJwNyEkRwDAMBDBKbnzDsXey/CGkeso1vkBaeJjTqQfuZE+h8sbdQ03JLhNO7CyhlUQL/sV9Jh4Rqw== (6 Nov 2012 16:39:12 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Tue, 6 Nov 2012 16:39:12 +0000 (UTC)
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)
X-User-ID eJwFwQcBADAIAzBLFGiHHXbwL2EJQ9BZKSo5HLvOE95W1HakNNWvsBczDeWYuAMZ1GDYBwFXD8U=
Cancel-Lock sha1:AtQI6UK5ymmOVzRoSdxk29nO0zo= sha1:qJe/yZOJVNbond5xXnwjO4vy4rc=
X-NNTP-Posting-Host eJwNytEVADEEBMCWiLWkHOfRfwm5+R43KjtAJ3x9a6qgiEQNN/VcGbEzB7ANifv1dFgW5Q+KBxlyEMk=
Xref csiph.com comp.emacs:1619

Show key headers only | View raw


lwoj.sjuwklim@gmail.com writes:

> I'm visualizing some little piece of Lisp code that would maybe search
> for the string in question and each time it finds an occurrence, you
> could (or could you?) check the position of the found instance on the
> line and if it's in the first position, pretend it wasn't really found
> and keep going...can a person do that kind of thing with Emacs to
> solve this fellow's problem?

Here is some Emacs Lisp that I think does what you described:

(defun foo (re)
  (interactive "sRE: ")
  (while (and (re-search-forward re nil t)
			  (= (- (match-beginning 0) (point-at-bol)) 0))
	nil
	)
  )

Being a novice at programming and Emacs Lisp that might not be the
smartest way, not even a particularly good one, to write such a function.

Another possibility is to put '.+' in front of a regular expression to
exclude matched-strings at the beginning of a line.

--
Axel Wegen

Back to comp.emacs | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: Quickie - Regexp for a string not at the beginning of the line Rivka Miller <rivkaumiller@gmail.com> - 2012-10-25 18:08 -0700
  Re: Quickie - Regexp for a string not at the beginning of the line Ed Morton <mortonspam@gmail.com> - 2012-10-25 21:00 -0500
  Re: Quickie - Regexp for a string not at the beginning of the line Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-26 03:11 +0100
    Re: Quickie - Regexp for a string not at the beginning of the line Rivka Miller <rivkaumiller@gmail.com> - 2012-10-25 21:45 -0700
      Re: Quickie - Regexp for a string not at the beginning of the line Janis Papanagnou <janis_papanagnou@hotmail.com> - 2012-10-26 11:18 +0200
      Re: Quickie - Regexp for a string not at the beginning of the line Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-26 13:11 +0100
      Re: Quickie - Regexp for a string not at the beginning of the line Ed Morton <mortonspam@gmail.com> - 2012-10-26 07:32 -0500
  Re: Quickie - Regexp for a string not at the beginning of the line anon@anon.anon - 2012-10-25 23:22 -0400
  Re: Quickie - Regexp for a string not at the beginning of the line lwoj.sjuwklim@gmail.com - 2012-11-05 15:05 -0800
    Re: Quickie - Regexp for a string not at the beginning of the line Axel Wegen <axel.wegen@gmail.com> - 2012-11-06 17:39 +0100

csiph-web