From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: DaLoverhino Newsgroups: gmane.emacs.help Subject: Help with emacs regexp Date: Wed, 22 Aug 2007 18:32:16 -0000 Organization: http://groups.google.com Message-ID: <1187807536.204680.23470@m37g2000prh.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1187814070 14969 80.91.229.12 (22 Aug 2007 20:21:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 22 Aug 2007 20:21:10 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 22 22:21:09 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1INwhN-0004ug-Fg for geh-help-gnu-emacs@m.gmane.org; Wed, 22 Aug 2007 22:21:05 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1INwhN-000528-0O for geh-help-gnu-emacs@m.gmane.org; Wed, 22 Aug 2007 16:21:05 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!m37g2000prh.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 69 Original-NNTP-Posting-Host: 216.57.82.2 Original-X-Trace: posting.google.com 1187807536 24542 127.0.0.1 (22 Aug 2007 18:32:16 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 22 Aug 2007 18:32:16 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: m37g2000prh.googlegroups.com; posting-host=216.57.82.2; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Original-Xref: shelby.stanford.edu gnu.emacs.help:151183 X-Mailman-Approved-At: Wed, 22 Aug 2007 16:19:55 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:46759 Archived-At: 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 The above strips everything but the braces, but also removes return type of all functions but the first. "^\(\s-\|{\}\)+.*" replace with 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 Ofcourse, the easiest method would be to: shell-command-on-region egrep '^\w' Can anyone help me out? Thanks.