({{, (RefLink[StringPartition, paclet:ref/StringPartition])["string",n] 
partitions string into nonoverlapping substrings of length n.}, {, (RefLink[StringPartition, paclet:ref/StringPartition])["string",n,d]
generates substrings with offset d.}})

OpenersNotesSection(Spacer1)Details

All the substrings generated by (RefLink[StringPartition, paclet:ref/StringPartition])[string,n,d] are of length n. Some elements at the end of string may therefore not appear in any substring.

(RefLink[StringPartition, paclet:ref/StringPartition])[string,(RefLink[UpTo, paclet:ref/UpTo])[n]] partitions into substrings of length up to n, allowing the final substring to be shorter.

All elements of string appear in the substrings generated by (RefLink[StringPartition, paclet:ref/StringPartition])[string,n,1].

If d is greater than n in (RefLink[StringPartition, paclet:ref/StringPartition])[string,n,d], then elements in the middle of string are skipped.

OpenersPrimaryExamplesSection(Spacer1)Examples  (5)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Partition a string into substrings of length 9:

StringPartition["123456789123456789",9]

Partition a string with an offset of 1:

StringPartition["123456789", 2,1]

Partition a string into substrings, including the shorter string at the end:

StringPartition["123456789",UpTo[2]]

OpenersExampleSection2(Spacer1)Possible Issues  (1)

Some elements of the original string may not appear in any substring:

StringPartition["ababababab",3]

OpenersExampleSection3(Spacer1)Neat Examples  (1)

Partition a sequence of base pairs into codons:

genome = GenomeData["SCNN1A","FullSequence"];

StringPartition[genome, 3]//Short

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[StringJoin, paclet:ref/StringJoin])  ▪  (RefLink[StringRepeat, paclet:ref/StringRepeat])  ▪  (RefLink[StringSplit, paclet:ref/StringSplit])  ▪  (RefLink[StringTake, paclet:ref/StringTake])  ▪  (RefLink[Partition, paclet:ref/Partition])  ▪  (RefLink[InsertLinebreaks, paclet:ref/InsertLinebreaks])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[String Operations, paclet:guide/StringOperations])}, {▪(RefLinkPlain[Text Analysis, paclet:guide/TextAnalysis])}})}})