: replace-foo-with-bar ( string -- string' ) [EBNF foo = "foo" => [[ "bar" ]] non-foo = (!(foo).)+ => [[ >string ]] text = (foo | non-foo)* EBNF] concat ; ( scratchpad ) "hello foo world, foo!" replace-foo-with-bar . "hello bar world, bar!"