| Allegro CL version 8.2 Moderately revised from 8.1. 8.1 version |
Arguments: regexp string bindings &body body
regexp and bindings are the
same as of re-lambda. string must be
an expression that evaluates to a string. This macro evaluates
string, matches it with
regexp, and if it matches, bind variables with
(sub)matches according to bindings, then
evaluates body. If string
doesn't match regexp, body
is not evaluated and nil
is returned.
See also re-case and re-lambda.
cl-user(4): (setq f (re-lambda "([^ ]+) ([^ ]+) ([^ ]+)" ((foo 1) (bar 2) (baz 3)) (list foo bar baz))) #<Interpreted Function (unnamed) @ #x71ed7892> cl-user(5): (funcall f "foo the bar") ("foo" "the" "bar") cl-user(6): (re-let "([^ ]+) ([^ ]+) ([^ ]+)" "foo the bar" ((foo 1) (bar 2) (baz 3)) (list foo bar baz)) ("foo" "the" "bar") cl-user(7): cl-user(9): (re-case "foo the barmy" ("foo a (.*)" ((it 1)) (list it)) ("foo the (.*)" ((it 1)) (list it)) (t :no-match)) ("barmy") cl-user(10): (re-case "foo a barmy" ("foo a (.*)" ((it 1)) (list it)) ("foo the (.*)" ((it 1)) (list it)) (t :no-match)) ("barmy") cl-user(11): (re-case "foo xx barmy" ("foo a (.*)" ((it 1)) (list it)) ("foo the (.*)" ((it 1)) (list it)) (t :no-match)) :no-match cl-user(12): cl-user(29): (re-let "(abc|def)(.*)" "defabc" ((a 0) (b 1) (c 2)) (list a b c)) ("defabc" "def" "abc") cl-user(30):
The symbol naming this operator is also exported from the regexp package.
See The new regexp2 module in regexp.htm for further information on this macro and the regexp2 module.
Copyright (c) 1998-2016, Franz Inc. Oakland, CA., USA. All rights reserved.
This page has had moderate revisions compared to the 8.1 page.
Created 2016.6.21.
| Allegro CL version 8.2 Moderately revised from 8.1. 8.1 version |