From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier " Newsgroups: gmane.emacs.help Subject: Re: On refining regexp by adding exceptions systematically Date: 05 Oct 2002 12:11:30 -0400 Organization: Yale University Sender: help-gnu-emacs-admin@gnu.org Message-ID: <5lelb4j26l.fsf@rum.cs.yale.edu> References: <9e8ebeb2.0210030427.4544cb00@posting.google.com> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1033835245 7562 127.0.0.1 (5 Oct 2002 16:27:25 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 5 Oct 2002 16:27:25 +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 17xrlz-0001xk-00 for ; Sat, 05 Oct 2002 18:27:23 +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 17xrkl-0007QI-00; Sat, 05 Oct 2002 12:26:07 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!cyclone.bc.net!news-hog.berkeley.edu!ucberkeley!news.ycc.yale.edu!rum.cs.yale.edu!rum.cs.yale.edu Original-Newsgroups: gnu.emacs.help Original-Lines: 22 Original-NNTP-Posting-Host: rum.cs.yale.edu User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-Original-NNTP-Posting-Host: rum.cs.yale.edu X-Original-Trace: 5 Oct 2002 12:11:30 -0400, rum.cs.yale.edu Original-Xref: shelby.stanford.edu gnu.emacs.help:105753 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:2299 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:2299 >> 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. 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. Stefan