WLJS LogoWLJS Notebook

StringTakeDrop

StringTakeDrop["string", n] gives a pair of strings containing the first n characters in "string" and the remaining characters.

  • StringTakeDrop["string", seq] gives the pair {StringTake["string", seq], StringDrop["string", seq]}.

Examples

Split a string at position 5:

StringTakeDrop["Hello World", 5]
(* {"Hello", " World"} *)

Take and drop last 3 characters:

StringTakeDrop["abcdefgh", -3]
(* {"abcde", "fgh"} *)

With range specification:

StringTakeDrop["Hello World", {1, 5}]
(* {"Hello", " World"} *)

Please visit the official Wolfram Language Reference for more details.

On this page