unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: DaLoverhino <DaLoveRhino@hotmail.com>
To: help-gnu-emacs@gnu.org
Subject: Help with emacs regexp
Date: Wed, 22 Aug 2007 18:32:16 -0000	[thread overview]
Message-ID: <1187807536.204680.23470@m37g2000prh.googlegroups.com> (raw)

Hello.  I'm trying to get a little fancier with regexp, but I there's
always this big gulf to the next plain which I can't seem to jump.  :)

I've been trying to write a regexp where all lines that begin with a
white space or opening and closing braces are removed.


I have a C-module with function definitions, and I want to strip out
everything in
the file, but leave the function signature and return type.

So the file looks like this:


static returnType
function1(blah, blah)
{
  if( blah)
  {
    blah;
  }
  blah;
}



returnType
function2(blah, blah)
{
  blah;
  blah;
}

I want it to look like the following after replace-regexp:

static returnType
function1(blah, blah)
returnType
function2(blah, blah)


Here's what I have, it only works partly:

"^\s-+.*
" replace with <nothing>

The above strips everything but the braces, but also removes return
type of all functions but the first.


"^\(\s-\|{\}\)+.*" replace with <nothing>

The above strips everything but the function signature, but it removes
the return type, and leaves a bunch of blank lines.

This doesn't work either:

"^[^a-zA-Z0-9]+?.*\n" replace with <nothing>



Ofcourse, the easiest method would be to:

shell-command-on-region
egrep '^\w'


Can anyone help me out?  Thanks.

             reply	other threads:[~2007-08-22 18:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-22 18:32 DaLoverhino [this message]
2007-08-22 18:41 ` Help with emacs regexp DaLoverhino
2007-08-23  1:26   ` Joe Fineman

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=1187807536.204680.23470@m37g2000prh.googlegroups.com \
    --to=daloverhino@hotmail.com \
    --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).