From: Alan Mackenzie<none@example.invalid>
Subject: Re: On refining regexp by adding exceptions systematically
Date: Sat, 5 Oct 2002 17:45:04 +0000 [thread overview]
Message-ID: <0f8nna.ud1.ln@acm.acm> (raw)
In-Reply-To: 5lelb4j26l.fsf@rum.cs.yale.edu
"Stefan Monnier <foo@acm.com>"
<monnier+gnu.emacs.help/news/@flint.cs.yale.edu> 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").
next prev parent reply other threads:[~2002-10-05 17:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-03 12:27 On refining regexp by adding exceptions systematically gnuist
2002-10-03 18:38 ` Kaz Kylheku
2002-10-03 23:04 ` Kaz Kylheku
[not found] ` <tvikna.obd.ln@lart.ca>
2002-10-07 14:13 ` Rodney Sparapani
2002-10-05 13:31 ` Alan Mackenzie
2002-10-05 16:11 ` Stefan Monnier <foo@acm.com>
2002-10-05 17:45 ` Alan Mackenzie [this message]
2002-10-06 3:02 ` Vassil Nikolov
2002-10-06 7:48 ` Alan Mackenzie
2002-10-05 19:46 ` Christopher Browne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0f8nna.ud1.ln@acm.acm \
--to=none@example.invalid \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).