Non-overlapping text search
Posted: Fri Feb 13, 2015 4:07 pm
The result of Find function ⍷ can be over overlapped.
Function textSearch implementes :While loop to remove overlapping.
Is there faster way to remove overlapping (except to use regular expressions)?
Function textSearch implementes :While loop to remove overlapping.
Code: Select all
∇b←srchfor textSearch srchin;size;b1;ix;⎕ML
⎕ML←0
b←srchfor⍷srchin
size←⊃⍴,srchfor
:While ∨/b1←(1↓ix)<size+¯1↓ix←{⍵/⍳⍴⍵}b ⍝ Check overlapping.
b[⊃b1/1↓ix]←0
:EndWhile
∇
Code: Select all
'aba' textSearchBool'babababababa'
0 1 0 0 0 1 0 0 0 1 0 0
Is there faster way to remove overlapping (except to use regular expressions)?