How to quickly split an ASCII string into equal sized junks?

Eg groups of 3 or 5 or 10 or 50 from an ASCII string.

I can think of two ways:

  • Use Mid -> probably slow
  • put string into a memoryblock and grab the junks from there

Any other idea that I miss?

use left(chunksize) and pull each “chunk” off and stuff them into a new array of chunks ?

Not sure what you mean by “pull each chunk off”. What I want to achieve is:

GATCGAATCGGTCGCAATGGGCATATATACTCHATC…

to

GAT CGA ATC GGT CGC AAT GGG CAT ATA TAC TCH ATC …

or

GATCG AATCG GTCGC AATGG GCATA TATAC TCHAT C…

or …

Can’t see that working with Left.

its probably not much different that using mid when its all said & done
which if you’re talking long DNA sequences could be quite slow (its has really odd performance characteristics at times)

dumping it into a memoryblock and pulling out strings based on offset & length might work out a lot quicker than mid would

something like

dim tmp as memoryblock = originalstring
for offset = 0 to tmp.Length step chunksize
       chunks.append tmp.stringvalue(offsetm chunksize)
next

ought to be kind of close

That’s what I thought. Just wondered if I overlooked another solution.

Thanks.