all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Help with emacs regexp
@ 2007-08-22 18:32 DaLoverhino
  2007-08-22 18:41 ` DaLoverhino
  0 siblings, 1 reply; 3+ messages in thread
From: DaLoverhino @ 2007-08-22 18:32 UTC (permalink / raw)
  To: help-gnu-emacs

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-08-23  1:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-22 18:32 Help with emacs regexp DaLoverhino
2007-08-22 18:41 ` DaLoverhino
2007-08-23  1:26   ` Joe Fineman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.