From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Bingham, Jay" Newsgroups: gmane.emacs.help Subject: RE: Newbie regexp question Date: Wed, 30 Oct 2002 10:57:31 -0600 Sender: help-gnu-emacs-admin@gnu.org Message-ID: <72A87F7160C0994D8C5A36E2FDC227F503925F69@txnexc01.americas.cpqcorp.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: main.gmane.org 1036001563 1879 80.91.224.249 (30 Oct 2002 18:12:43 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 30 Oct 2002 18:12:43 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 186xKX-0000TM-00 for ; Wed, 30 Oct 2002 19:12:38 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 186xKE-0002pP-00; Wed, 30 Oct 2002 13:12:18 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 186wA3-0001ux-00 for help-gnu-emacs@gnu.org; Wed, 30 Oct 2002 11:57:43 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 186w9y-0001mG-00 for help-gnu-emacs@gnu.org; Wed, 30 Oct 2002 11:57:41 -0500 Original-Received: from zcamail04.zca.compaq.com ([161.114.32.104]) by monty-python.gnu.org with esmtp (Exim 4.10) id 186w9w-0001jH-00 for help-gnu-emacs@gnu.org; Wed, 30 Oct 2002 11:57:37 -0500 Original-Received: from cacexg12.americas.cpqcorp.net (cacexg12.americas.cpqcorp.net [16.105.250.119]) by zcamail04.zca.compaq.com (Postfix) with ESMTP id 3B882CE4 for ; Wed, 30 Oct 2002 08:57:36 -0800 (PST) Original-Received: from txnexc01.americas.cpqcorp.net ([16.74.7.244]) by cacexg12.americas.cpqcorp.net with Microsoft SMTPSVC(5.0.2195.2966); Wed, 30 Oct 2002 08:57:32 -0800 X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Newbie regexp question Thread-Index: AcKAK9u05Ho3PN24TnibewfdXsPlQQAAtlNA Original-To: X-OriginalArrivalTime: 30 Oct 2002 16:57:32.0637 (UTC) FILETIME=[705A18D0:01C28035] Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:3121 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:3121 Fredrich, It is too bad that you do not understand what Paul wants to do. Paul, Here is what I understand you want to do:=20 find the next occurrence of , find the next occurrence = , delete everything between the start of = and end of , do this repeatedly in the buffer. There are some problems with your approach to this. First, you did not end the pattern with an end of line (you = should probably also end the pattern with an end of = line, unless you want a blank line where these were found). Second, regexp does not recognize "\n" as a new line it just puts an "n" = in the pattern. In order to match new lines you have to put literal new = line characters in the pattern. This is done with the C-q C-j sequence. Third, even if you make the above corrections and produce the following = pattern: ^[ \t]* \(.* \)*[ \t]* it still will not do what you want it to do. The reason that it won't = is that the asterisk at the end of the sub-pattern \(.* \)* tells emacs to match as many as possible of the preceding = sub-pattern. So this will match from the start of the first = to the end of the last . Not exactly what I think you = had in mind. The only way that I know to do what you want to do is to write a = function to do it. This function would prompt for the first pattern, = then prompt for the second pattern, then prompt for a replacement = string. It would then search for the first pattern, save the start = location of the first pattern, search for the second pattern and replace = the range between the start of the first pattern and the end of the = second pattern with the replacement string. (I say replacement string = rather than pattern because the \DIGIT meta which is the only pattern = meta that is of use in a replacement pattern would not work without = doing some special coding in the function to simulate its operation). I used to have a function that would delete everything between two = patterns, but when I left my last employer I failed to capture a copy of = it. I kick my self quite often for not capturing the functions that I = developed there. -_ J_) C_)ingham . HP - NonStop Austin Software & Services - Software Quality = Assurance . Austin, TX . Language is the apparel in which your thoughts parade in public. . Never clothe them in vulgar and shoddy attire. -Dr. George W. = Crane- -----Original Message----- From: Friedrich Dominicus [mailto:frido@q-software-solutions.com]=20 Sent: Wednesday, October 30, 2002 9:34 AM To: help-gnu-emacs@gnu.org Subject: Re: Newbie regexp question Paul Cohen writes: > Hi >=20 > I want to do a Emacs regexp search and replace on a HTML file = containing > patterns like this: >=20 > > ... > >=20 > Where "..." denotes a variable number of lines of HTML text. >=20 > I want to search for all occurrences of the above pattern and then > remove them from the HTML file! >=20 > I've tried a number of variants without any success. For example the > following regexp doesn't work: >=20 > \(.*\n\)* I would restate the problem. It does not make much sense to me to match over a bunch of lines you do not want to handle.=20 So how about M-C-% ^[ \t]* with: RET Or even better if you kow exactly what you are looking for using replace-string? Regards Friedrich _______________________________________________ Help-gnu-emacs mailing list Help-gnu-emacs@gnu.org http://mail.gnu.org/mailman/listinfo/help-gnu-emacs