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

clisp, regexp:match, and subgroups?

35 views
Skip to first unread message

Mike

unread,
May 2, 2012, 12:49:52 PM5/2/12
to
Thank you everyone on my previous (loop...) question. I understand now
more than I did. My next stumbling stone is (regexp:match...). I have
this function where it is matching a pattern. I'm trying to extract
that pattern. I found where the POSIX regexps will match subgroups.
Great. I have the matching working. Now, how do I see any subgroup other
than the first one? I found a mention of a (multi-value-bind...),
but clisp says that function doesn't exist. How do I access the
other-than-first matches?

Mike

Mirko Vukovic

unread,
May 2, 2012, 3:15:39 PM5/2/12
to
multiPLE-value-bind

Mike

unread,
May 2, 2012, 4:00:41 PM5/2/12
to
Mirko,

Thank you. Do you have an example of using it?

Mike

Mike

unread,
May 2, 2012, 4:10:29 PM5/2/12
to
Turns out I can do it this way:

(regexp:match-start (cadr (multiple-value-list (regexp:match pattern z))))

I got this hint from: <http://www.lispworks.com/documentation/HyperSpec/Body/f_vals_l.htm>

Mike

WJ

unread,
May 2, 2012, 5:20:18 PM5/2/12
to
Racket:

> (regexp-match "(...) (...)" "foo bar")
'("foo bar" "foo" "bar")

Mirko Vukovic

unread,
May 2, 2012, 8:11:15 PM5/2/12
to
You got it - hyperspec is your friend :-)

Tim Bradshaw

unread,
May 3, 2012, 7:02:42 AM5/3/12
to
On 2012-05-02 20:10:29 +0000, Mike said:

> (regexp:match-start (cadr (multiple-value-list (regexp:match pattern z))))

Much more idiomatic would be (nth-value 1 ...) (counting from 0, so
this is the second value)

0 new messages