
file:///files/lisp/email/cl-ppcre/doc/index.html#scan On success returns four values and 2 arrays. But not in a list? How to access these values please? TIA -- Dave Pawson XSLT XSL-FO FAQ. http://www.dpawson.co.uk

Hi Dave, If I understand your question correctly, you want to look at multiple- value-bind. This lets you bind multiple return values (hence the name :->). E.g., (completely untested code) (mulitple-value-bind (a b c d array-1 array-2) (cl-ppcre:scan ...) ;; now a, b, c, d, array-1 and array-2 are bound to the values returned from scan ...) HTH On Jul 7, 2008, at 7:22 AM, Dave Pawson wrote:
file:///files/lisp/email/cl-ppcre/doc/index.html#scan
On success returns four values and 2 arrays. But not in a list?
How to access these values please?
TIA
-- Dave Pawson XSLT XSL-FO FAQ. http://www.dpawson.co.uk _______________________________________________ cl-ppcre-devel site list cl-ppcre-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-ppcre-devel
-- Gary Warren King, metabang.com Cell: (413) 559 8738 Fax: (206) 338-4052 gwkkwg on Skype * garethsan on AIM

2008/7/7 Gary King <gwking@metabang.com>:
Hi Dave,
If I understand your question correctly, you want to look at multiple-value-bind. This lets you bind multiple return values (hence the name :->). E.g., (completely untested code)
(mulitple-value-bind (a b c d array-1 array-2) (cl-ppcre:scan ...) ;; now a, b, c, d, array-1 and array-2 are bound to the values returned from scan
Simpler question then. How to test for a simple, full match? regex="ABC" testString="ABC" scan or scan-to-strings seems to be the correct choice? regards -- Dave Pawson XSLT XSL-FO FAQ. http://www.dpawson.co.uk

Try something like this: (defun full-match-p (regex string) (multiple-value-bind (start end array-1 array-2) (cl-ppcre:scan regex string) (declare (ignore array-1 array-2)) (and (= start 0) (= end (length string))))) On Jul 7, 2008, at 8:14 AM, Dave Pawson wrote:
2008/7/7 Gary King <gwking@metabang.com>:
Hi Dave,
If I understand your question correctly, you want to look at multiple-value-bind. This lets you bind multiple return values (hence the name :->). E.g., (completely untested code)
(mulitple-value-bind (a b c d array-1 array-2) (cl-ppcre:scan ...) ;; now a, b, c, d, array-1 and array-2 are bound to the values returned from scan
Simpler question then.
How to test for a simple, full match?
regex="ABC" testString="ABC"
scan or scan-to-strings seems to be the correct choice?
regards
-- Dave Pawson XSLT XSL-FO FAQ. http://www.dpawson.co.uk _______________________________________________ cl-ppcre-devel site list cl-ppcre-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-ppcre-devel
-- Gary Warren King, metabang.com Cell: (413) 559 8738 Fax: (206) 338-4052 gwkkwg on Skype * garethsan on AIM

On Mon, 7 Jul 2008 09:45:11 -0400, Gary King <gwking@metabang.com> wrote:
Try something like this:
(defun full-match-p (regex string) (multiple-value-bind (start end array-1 array-2) (cl-ppcre:scan regex string) (declare (ignore array-1 array-2)) (and (= start 0) (= end (length string)))))
Simpler: (scan "^ABC$" "ABC") (scan "^ABC$" "ABCD") The first return value of SCAN serves as a generalized boolean.

Oh, and BTW... On Mon, 7 Jul 2008 09:45:11 -0400, Gary King <gwking@metabang.com> wrote:
(multiple-value-bind (start end array-1 array-2) (cl-ppcre:scan regex string) (declare (ignore array-1 array-2)) ...)
That's equivalent to (multiple-value-bind (start end) (cl-ppcre:scan regex string) ...) Edi.

Thanks Edi, (I can never remember whether mvb is nice about ignoring "unclaimed" values). The use of ^ and $ is, of couse, also much preferred. On Jul 7, 2008, at 9:49 AM, Edi Weitz wrote:
Oh, and BTW...
On Mon, 7 Jul 2008 09:45:11 -0400, Gary King <gwking@metabang.com> wrote:
(multiple-value-bind (start end array-1 array-2) (cl-ppcre:scan regex string) (declare (ignore array-1 array-2)) ...)
That's equivalent to
(multiple-value-bind (start end) (cl-ppcre:scan regex string) ...)
Edi. _______________________________________________ cl-ppcre-devel site list cl-ppcre-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-ppcre-devel
-- Gary Warren King, metabang.com Cell: (413) 559 8738 Fax: (206) 338-4052 gwkkwg on Skype * garethsan on AIM

Getting there. Thanks for the hints (setq res (cl-ppcre:register-groups-bind (first second ) ("^Topics messages ([0-9]+) through ([0-9]+)" "Topics messages 1 through 99" :sharedp t) (list first second ) )) (if res (msg(concatenate 'string "<message st=\"" (car res) "\" end=\"" (cadr res) "\"/>")) ) That gives me what I wanted. Now returns the marked up parse of the string or nil. I can work with that! Much appreciated. -- Dave Pawson XSLT XSL-FO FAQ. http://www.dpawson.co.uk
participants (3)
-
Dave Pawson
-
Edi Weitz
-
Gary King