StringDrop

StringDrop["string",n]

gives "string" with its first n characters dropped.

StringDrop["string",-n]

gives "string" with its last n characters dropped.

StringDrop["string",{n}]

gives "string" with its n^(th) character dropped.

StringDrop["string",{m,n}]

gives "string" with characters m through n dropped.

StringDrop[{s1,s2,},spec]

gives the list of results for each of the s_(i).

Details

  • StringDrop["string",UpTo[n]] removes n characters, or as many as are available.
  • StringDrop["string",{m,n,s}] drops characters m through n in steps of s.
  • StringDrop uses the standard Wolfram Language sequence specification.

Examples

open allclose all

Basic Examples  (3)

Drop the first 4 characters from a string:

Use InputForm to show quotes:

Drop from the end of the string:

Drop characters 5 through 10:

Scope  (5)

Drop character 3 from a string:

Drop every other character:

Drop the last 2 characters from several strings:

StringDrop works with special characters:

Drop the first 4 characters if possible, else as many as are available:

Properties & Relations  (3)

Newline (\n) counts as a single character:

StringDrop works like applying Drop to the list of characters:

StringReplacePart with an empty string can be used like StringDrop:

StringReplacePart can drop several sequences of characters at a time:

Possible Issues  (1)

StringDrop operates on the raw characters in a string:

Introduced in 1991
 (2.0)
 |
Updated in 1999
 (4.0)
2000
 (4.1)
2002
 (4.2)
2004
 (5.1)
2014
 (10.0)
2015
 (10.3)