Yet another variation on the overlap version: 'AA' (] #~ #@[ */\ (<:@##1:)@[ , -.@E.) 'abcAAAdefAAA'
On Sun, 30 Aug 2020 21:03:37 -0400 Raul Miller <[email protected]> wrote: > Well, if you want the alternate semantics you suggested in that comment: > > 'AA' (] rplc '';~[) 'abcAAAdefAAA' > abcAdefA > > Or, if you prefer the overlap approach: > > 'AA' (] #~ #@[ */@(-@i.@[ |."_1 #) -.@,:@E.) 'abcAAAdefAAA' > abcdef > > I hope this helps, > > -- > Raul > > On Sun, Aug 30, 2020 at 8:56 PM Devon McCormick <[email protected]> wrote: > > > > Hi - > > > > I just wrote a string removal verb: > > > > NB.* removeStr: remove string x from string y > > removeStr=: 4 : 0 > > wh=. I. whb=. x E. y > > rmb=. -. (1) (~.;(<i.#x)+&.>wh)}whb > > rmb#y > > NB.EG 'H n brn c?' -: 'ow' removeStr 'How now brown cow?' > > NB.EG 'abcdef' -: 'AA' removeStr 'abcAAAdefAAA' NB. May be non-intuitive > > ) > > > > Note the second example in the comment on the final line - since 'AA' > > occurs twice in 'AAA', both are removed, thus removing the triplet. It > > seems an unlikely case but is this behavior too confusing? > > > > Does anyone have an alternate version of this? > > > > Thanks, > > > > Devon > > -- > > > > Devon McCormick, CFA > > > > Quantitative Consultant > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
