I'm still struggling to master match and set-ref-all.
(set 'lst '(
("a" "1")
("b" "2")
("c" "3")
))
(set-ref-all (lst '(* ("b" *) *)) (println $0) match)
Is this sort of search possible?
Your match expression
'(* ("b" *) *)
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:
'("b" *)
and that would produce:
(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
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!