From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Regular expression converter.
Date: Sun, 09 Nov 2003 19:23:29 -0500 [thread overview]
Message-ID: <m3fzgxgjge.fsf@asfast.com> (raw)
In-Reply-To: Lloyd Zusman's message of "Sun, 09 Nov 2003 14:45:45 -0500"
[-- Attachment #1: Type: text/plain, Size: 1661 bytes --]
Lloyd Zusman <ljz@asfast.com> writes:
> [ ... ]
>
> As an example, this proposed function/macro would convert the expression
> marked as "Perl" to the one marked "Emacs" (note that I'm writing these
> as if they would appear inside of an Elisp string, and therefore, the
> backslashes are all doubled):
>
> Perl: ^(.+?\\.)+(com|net|org)$
> Emacs: ^\\(.+?\\.\\)+\\(com\\|net\\|org\\)$
>
> [ ... ]
Well, I found something. In case anyone is interested, I'm enclosing
it.
It's something that was originally called "rx.el", and it implements
some functions and macros that permit a less-backslash-laden regular
expression syntax. It's by Will Mengarini <seldon@eskimo.com> and it
was written in 1998/1999.
Because its name conflicts with the current "rx.el", I have renamed it
to "xr.el" (with the package name being "xr" instead of "rx").
It implements the syntax I want, with the small exception being that it
uses the backtick (`) instead of the backslash (\) as its escape
character. To me, that's a small price to pay for more readability.
The xr syntax for the regular expression above would be this:
^(.+?`.)+(com|net|org)$
It also implements a few functions that correspond to standard elisp
functions, but which use this alternate regexp syntax:
xr= corresponds to `string-match'
xr@ corresponds to `looking-at'
xr-search-forward corresponds to `re-search-forward'
xr-search-backward corresponds to `re-search-backward'
xr-query-replace corresponds to `query-replace-regexp'
I've already put this package into much of my commonly used elisp code,
and it is working very nicely.
[-- Attachment #2: xr.el --]
[-- Type: application/emacs-lisp, Size: 17105 bytes --]
[-- Attachment #3: Type: text/plain, Size: 36 bytes --]
--
Lloyd Zusman
ljz@asfast.com
prev parent reply other threads:[~2003-11-10 0:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-09 19:45 Lloyd Zusman
2003-11-09 19:58 ` Jesper Harder
2003-11-09 22:56 ` Lloyd Zusman
2003-11-10 0:23 ` Lloyd Zusman [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3fzgxgjge.fsf@asfast.com \
--to=ljz@asfast.com \
/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 NNTP newsgroup(s).