[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Help with emacs regexp
From: |
DaLoverhino |
Subject: |
Help with emacs regexp |
Date: |
Wed, 22 Aug 2007 18:32:16 -0000 |
User-agent: |
G2/1.0 |
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.
- Help with emacs regexp,
DaLoverhino <=