WLJS LogoWLJS Notebook

StringPartition

StringPartition["string", n] partitions string into nonoverlapping substrings of length n.

StringPartition["string", n, d] generates substrings with offset d.

Examples

Partition into chunks:

StringPartition["abcdefgh", 2]
(* {"ab", "cd", "ef", "gh"} *)

Overlapping partitions:

StringPartition["abcdef", 3, 1]
(* {"abc", "bcd", "cde", "def"} *)

Please visit the official Wolfram Language Reference for more details.

On this page