[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using non-Emacs regexp syntax

From: Stuart D. Herring
Subject: Re: using non-Emacs regexp syntax
Date: Fri, 1 Dec 2006 14:35:00 -0800 (PST)
User-agent: SquirrelMail/1.4.6-7.el3.7lanl

> If you don't mind, I'll work on it now.  Changes can be added to whatever
> .el file in the distribution later.
> Also, is there sense in supporting conversion to and from several formats?
> E.g. some require that plus operator is escaped, while everything else is
> not.  E.g. something like this:
>       (convert-regexp :sed :emacs some-regexp)
>                       FROM   TO   PATTERN-STRING
> Of course, it will add more complexity, but it shouldn't be much of a
problem for users of this function and implementing it in Lisp should
> be not hard.

I've already started on this sort of thing, writing a converter just
between the two formats supported by GNU grep.  (These are
"GNU-extended-basic-RE" and "extended-RE with backreferences".)  As it
happens, that conversion can be done with one function because the formats
are so similar.  I had planned to go on to the more general case, but for
now I'll just provide what I have for comment and/or use.  (I have papers,
so any use is fine.)  If, Paul, you'd like, we can collaborate on this, or
one of us of your choice can go on with it.

For reference/goal purposes, I've been looking at the (somewhat outdated)
Mastering Regular Expressions and it describes these syntaxes:
1.  vi
2. (modern) grep
3. egrep
4. sed
5. lex
6. old awk
7. new awk(s) (don't know how different they really are from each other or
from old awk)
8. Emacs
9. Perl (obviously we can only convert a subset of Perl's syntax...)
10. Tcl
11. a Tcl library called Expect (although I don't know if/why it has a
different syntax from Tcl itself)
12. Python (complicated by the old regex and the new re packages, and how
the former had a variable syntax)

Hope it's helpful,

PS - I originally wrote this using some convenience macros of mine.  It
seems to work after I standardized it, but that's probably why if it

This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during

Attachment: convert-re.el
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]