Page 1 of 1
More set-ref-all and match questions
Posted: Fri Feb 15, 2008 5:51 pm
by cormullion
I'm still struggling to master
match and
set-ref-all.
Code: Select all
(set 'lst '(
("a" "1")
("b" "2")
("c" "3")
))
(set-ref-all (lst '(* ("b" *) *)) (println $0) match)
Is this sort of search possible?
Posted: Mon Feb 18, 2008 3:58 pm
by Lutz
Your match expression
would match the whole list, but set-ref-all (and all other ref's) try to find a match starting on each element of lst and then recursing into it. What you probably want as a match expression is:
and that would produce:
Code: Select all
(set 'lst '(
("a" "1")
("b" "2")
("c" "3")
("b" 1 2 3)
))
(set-ref-all (lst '("b" *)) (println $0) match)
("b" "2")
("b" 1 (2) 3)
; or
(set-ref-all (lst '("b" ?)) (println $0) match)
("b" "2")
(set-ref-all (lst '(*(?)*)) (println $0) match)
("b" 1 (2) 3)
... etc.
Lutz
Posted: Mon Feb 18, 2008 5:54 pm
by cormullion
Ah, thanks. I think I"m getting confused by the meaning of '*' in match and regex... '*' matches nothing, but I thought that otherwise it would match only at the beginning. Will study it some more until I get it!