Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to get groups out of match-regexp

30 views
Skip to first unread message

Charlie Benton

unread,
Aug 8, 2000, 3:00:00 AM8/8/00
to
Let's say I want to extract the first group from the regular expression
"author: \\(\\w+\\);". Documentation told me that if I set the :return
argument to :string then match-regexp would return a list where the
first group would be the 3rd member.

But the commmand (print (nth 2 (match-regexp "author: \\(\\w+\\);" "asdf
author: bentonc;" :return :string))) gives me an error. What am I doing
wrong.

Thanks,
Charlie Benton (ben...@mail.utexas.edu)


David J. Cooper

unread,
Aug 8, 2000, 3:00:00 AM8/8/00
to

I'm pretty sure he's talking about Emacs Lisp. Emacs has its own
newsgroup (gnu.emacs, right?), does Elisp have its own?

By the way, has that or a similar regexp function been ported to CL as
far as anyone knows? I had heard that Franz had some stuff on their
site (for Allegro, at least). If they can implement much of CL in
Elisp, why can't we implement some of the main Elisp functionalities
in CL even more easily? I find myself using `lep::eval-in-emacs' more
than I really should have to...

-dave


--
David J. Cooper Jr, Chief Engineer Genworks International
dco...@genworks.com 5777 West Maple, Suite 130
(248) 932-2512 (Genworks HQ/voicemail) West Bloomfield, MI 48322-2268
(248) 407-0633 (pager) http://www.genworks.com

Christopher C Stacy

unread,
Aug 9, 2000, 3:00:00 AM8/9/00
to
>>>>> On Tue, 08 Aug 2000 20:59:23 -0500, Charlie Benton ("Charlie") writes:

Charlie> Let's say I want to extract the first group from the regular expression
Charlie> "author: \\(\\w+\\);". Documentation told me that if I set the :return
Charlie> argument to :string then match-regexp would return a list where the
Charlie> first group would be the 3rd member.
Charlie> But the commmand
Charlie> (print (nth 2 (match-regexp "author: \\(\\w+\\);"
Charlie> "asdf author: bentonc;"
Charlie> :return :string)))
Charlie> gives me an error. What am I doing wrong.

Charlie,

The function named "match-regexp" is not part of the Common Lisp
language. Common Lisp does not include any regular expression feature
(though some would say that such would be a good addition). So, what
language are you programming in, and/or what library have you loaded?
It would also be helpful to know what the error message is.

Christian Lynbech

unread,
Aug 9, 2000, 3:00:00 AM8/9/00
to
>>>>> "David" == David J Cooper <dco...@genworks.com> writes:

David> I'm pretty sure he's talking about Emacs Lisp. Emacs has its own
David> newsgroup (gnu.emacs, right?), does Elisp have its own?

David> By the way, has that or a similar regexp function been ported to CL as
David> far as anyone knows? I had heard that Franz had some stuff on their
David> site (for Allegro, at least).

Regexp support is part of ACL (at least with version 5), though I do
not think that extraction of groups is supported. I rolled my own
interface to the UNIX regexp system using the ACL FFI. It is pretty
simple to do (code available on request).


---------------------------+--------------------------------------------------
Christian Lynbech | Ericsson Telebit, Fabrikvej 11, DK-8260 Viby J
Fax: +45 8675 6881 | email: c...@ericssontelebit.com
Phone: +45 8675 6828 | web: www.ericssontelebit.com
---------------------------+--------------------------------------------------
Hit the philistines three times over the head with the Elisp reference manual.
- pet...@hal.com (Michael A. Petonic)

Erik Naggum

unread,
Aug 9, 2000, 3:00:00 AM8/9/00
to
* Charlie Benton <ben...@mail.utexas.edu>

| Let's say I want to extract the first group from the regular expression
| "author: \\(\\w+\\);". Documentation told me that if I set the :return
| argument to :string then match-regexp would return a list where the
| first group would be the 3rd member.

Documentation told you that? That's pretty weird. The same
documentation tells me that the third _value_ is the first group.
At least if we're talking about the match-regexp that comes with in
Allegro CL.

| But the commmand (print (nth 2 (match-regexp "author: \\(\\w+\\);" "asdf

| author: bentonc;" :return :string))) gives me an error. What am I doing
| wrong.

Try nth-value instead of nth. (I would suggest you drop the print,
too, if you're doing this interactively.)

#:Erik
--
If this is not what you expected, please alter your expectations.

0 new messages