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

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 2012-11-06 17:39 +0100
Organization solani.org
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>

Show all headers | 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