replace←{(⍴v)↓∊(⊂v),¨(↑⍴u)↓¨(+\u⍷a)⊂a←u,⍺⊣(u v)←⍵}
Jay. On 12 April 2016 at 11:39, Elias Mårtenson <loke...@gmail.com> wrote: > I had a need to to replace substrings with a replacement, and I'm having a > hard time coming up with an concise solution. What I need to do is this: > > 'foobartestfootest' replace 'foo' 'xy' > > Should yield: > > 'xybartestxytest' > > Any suggestions? > > Regards, > Elias