From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: On refining regexp by adding exceptions systematically Date: Sat, 5 Oct 2002 17:45:04 +0000 Organization: muc.de e.V. -- private internet access Sender: help-gnu-emacs-admin@gnu.org Message-ID: <0f8nna.ud1.ln@acm.acm> References: <9e8ebeb2.0210030427.4544cb00@posting.google.com> <5lelb4j26l.fsf@rum.cs.yale.edu> NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1033851412 22595 127.0.0.1 (5 Oct 2002 20:56:52 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 5 Oct 2002 20:56:52 +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 17xvyk-0005sJ-00 for ; Sat, 05 Oct 2002 22:56:51 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17xvyO-0008Gu-00; Sat, 05 Oct 2002 16:56:28 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!feed.news.nacamar.de!news.csl-gmbh.net!informatik.tu-muenchen.de!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 46 Original-NNTP-Posting-Host: acm.muc.de Original-X-Trace: marvin.muc.de 1033850951 56634 193.149.49.134 (5 Oct 2002 20:49:11 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: 5 Oct 2002 20:49:11 GMT User-Agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686)) Original-Xref: shelby.stanford.edu gnu.emacs.help:105756 Original-To: help-gnu-emacs@gnu.org 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:2302 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:2302 "Stefan Monnier " wrote on 05 Oct 2002 12:11:30 -0400: >>> Here is regular expression in emacs lisp that initially seems to work >>> for the job: [A-Z][A-Z][A-Z][0-9]+ >>> After running it on a number of uses, I find that there is an exception >>> to it, namely PJP89898. Rather than rehashing the code after having >>> forgotten it and reworking my regexp expression (every time I find an >>> exception) in some convoluted way, is there a systematic way to add an >>> exception or a series of exceptions to the regexp? I am sure that there >>> are a number of ways to do this and each has its merits. >> Regular expressions are designed to find string expressions which are, >> well, regular. If you really want to add in an exception like you've >> got, you're going to end up with something horrible. It can be done, >> but like rowing the Atlantic, why bother? > Actually, the end would still be regular. But it's not currently > supported by Emacs' regexp engine. Sorry, what's not supported? > Oh and BTW, extended regular expressions (as seen in Emacs and egrep) > are actually not regular because of back-references. Perl regexps have > support for things like that. Hmm. Thanks, Stefan! ;-) I was just trying to help the guy. I'm not actually that well versed with the theory behind regexps. I read somewhere (that book with the young woman operating a Heath-Robinson contraption on the front cover, and the same thing broken on the back cover) that a regexp is equivalent to a finite-state-machine, in that if one of either of them can recognise a string, so can one of the other. Nevertheless, I think I know how to use them, more or less, and what they're good for, and what they're not good for. On their own, they're not good for the original poster's problem. > Stefan -- Alan Mackenzie (Munich, Germany) Email: aacm@muuc.dee; to decode, wherever there is a repeated letter (like "aa"), remove half of them (leaving, say, "a").