unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Cecil Westerhof <Cecil@decebal.nl>
To: help-gnu-emacs@gnu.org
Subject: I need help with a regular expression
Date: Fri, 16 Apr 2010 23:25:22 +0200	[thread overview]
Message-ID: <87ljcnw0n1.fsf@linux-lqcw.site> (raw)

I have written some code to count the number of functions in a buffer.
At the moment I use the following regular expression for this:
    "^(defun "

This works fine, but then the defun's have to be on the start of the
line. This is the most logical, but it is better to be save as sorry.
This is why I wanted to write a more robust regular expression. I was
thinking about something like:
    "^[^;]+(defun "

But that does not work. It marks the following completely, instead of
the three at its own:
    (defun a () (message "a"))
    (defun b () (message "b"))
    (defun c () (message "c"))

Why is this? And how can I make a regular expression that does what I
want?

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


             reply	other threads:[~2010-04-16 21:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-16 21:25 Cecil Westerhof [this message]
2010-04-16 22:16 ` I need help with a regular expression José A. Romero L.
2010-04-17  6:20   ` Cecil Westerhof
2010-05-04 21:21   ` Lennart Borgman
2010-05-05 15:51 ` J. David Boyd
     [not found] ` <mailman.7.1273074686.2155.help-gnu-emacs@gnu.org>
2010-05-06 10:17   ` Xah Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ljcnw0n1.fsf@linux-lqcw.site \
    --to=cecil@decebal.nl \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).