USING: kernel peg peg.search make sequences ; : (1action) ( str1 str2 -- action-parser ) [ token ] [ [ ] curry [ drop ] prepose ] bi* action ; : replace-all ( long-str seq-of-pairs -- str ) ! "some string" { { "om" "mop!" } { "s" "B" } } dupd [ [ first ] [ second ] bi (1action) ] with map [ [ , ] curry ] map concat choice* replace ; ! "something" { { "me" "you" } { "so" "so " } { "thing" " think?" } } replace-all