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]}.

Details

  • StringTakeDrop uses the standard sequence specification:
  • Allall characters
    Noneno characters
    ncharacters 1 through n
    UpTo[n]characters 1 up to at most n, as available
    -nlast n characters
    {n}character n only
    {m,n}characters m through n inclusive
    {m,n,s}characters m through n in steps of s
  • StringTakeDrop[{string1,string2,},seq] returns {StringTakeDrop[string1,seq],StringTakeDrop[string2,seq],}.
  • StringTakeDrop[BioSequence["type","seq"],spec] will apply the operation to the string "seq", yielding a BioSequence result.
  • Given a circular BioSequence and a starting position greater than the ending position, i.e. m>n, then StringTakeDrop[bioseq,{m,n}] takes the wrapped-around sequence starting at m and ending at n.

Examples

open allclose all

Basic Examples  (3)

Separate the first 6 characters in a string from the rest:

Take some characters from the middle of a string and catenate the rest:

Separate a string into substrings of given lengths:

Scope  (5)

StringTakeDrop uses the standard sequence specification:

Take up to 8 characters in the first string, or as many as are available:

StringTakeDrop is listable in its first argument:

Take and drop a codon from a biomolecular sequence:

Undertake a wraparound take and drop on a circular sequence:

Applications  (1)

Break a list of structured strings by given lengths:

This can also be achieved with StringTake using a list of sequence specs:

Properties & Relations  (2)

StringTakeDrop is equivalent to a combination of StringTake and StringDrop:

StringTakeDrop does for strings what TakeDrop does for lists:

Wolfram Research (2021), StringTakeDrop, Wolfram Language function, https://reference.wolfram.com/language/ref/StringTakeDrop.html (updated 2022).

Text

Wolfram Research (2021), StringTakeDrop, Wolfram Language function, https://reference.wolfram.com/language/ref/StringTakeDrop.html (updated 2022).

CMS

Wolfram Language. 2021. "StringTakeDrop." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/StringTakeDrop.html.

APA

Wolfram Language. (2021). StringTakeDrop. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/StringTakeDrop.html

BibTeX

@misc{reference.wolfram_2024_stringtakedrop, author="Wolfram Research", title="{StringTakeDrop}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/StringTakeDrop.html}", note=[Accessed: 24-April-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_stringtakedrop, organization={Wolfram Research}, title={StringTakeDrop}, year={2022}, url={https://reference.wolfram.com/language/ref/StringTakeDrop.html}, note=[Accessed: 24-April-2024 ]}