Snippet[doc]
gives a snippet of text from a document or other content object.
Snippet[doc,n]
gives about n lines from the beginning.
Snippet[doc,-n]
gives about n lines from the end.
Snippet[doc,n1;;n2]
gives a span from lines n1 to n2
Snippet[doc,n1;;n2;;n3]
gives a span from lines n1 to n2 in steps of n3.
Snippet[ContentObject[…],SearchResultObject[…]]
gives contextual snippets from a content object based on search results.


Snippet
Snippet[doc]
gives a snippet of text from a document or other content object.
Snippet[doc,n]
gives about n lines from the beginning.
Snippet[doc,-n]
gives about n lines from the end.
Snippet[doc,n1;;n2]
gives a span from lines n1 to n2
Snippet[doc,n1;;n2;;n3]
gives a span from lines n1 to n2 in steps of n3.
Snippet[ContentObject[…],SearchResultObject[…]]
gives contextual snippets from a content object based on search results.
Examples
open all close allBasic Examples (1)
Show a snippet of text contained in a ContentObject:
Note that for ContentObject there is an equivalent form:
Related Guides
Related Workflows
- Shorten Long Outputs
Text
Wolfram Research (2015), Snippet, Wolfram Language function, https://reference.wolfram.com/language/ref/Snippet.html (updated 2016).
CMS
Wolfram Language. 2015. "Snippet." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/Snippet.html.
APA
Wolfram Language. (2015). Snippet. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Snippet.html
BibTeX
@misc{reference.wolfram_2025_snippet, author="Wolfram Research", title="{Snippet}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/Snippet.html}", note=[Accessed: 12-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_snippet, organization={Wolfram Research}, title={Snippet}, year={2016}, url={https://reference.wolfram.com/language/ref/Snippet.html}, note=[Accessed: 12-August-2025]}