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.

Details and Options

  • The default value for n is 1.
  • Snippet[File[]] and Snippet[URL[]] give snippets from files and URLs, respectively.

Examples

open allclose all

Basic Examples  (1)

Show a snippet of text contained in a ContentObject:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Show only the first 3 lines:

In[3]:=
Click for copyable input
Out[3]=

Note that for ContentObject there is an equivalent form:

In[4]:=
Click for copyable input
Out[4]=

Scope  (2)

See Also

ContentObject  StringTake  Thumbnail  TextWords  WordCloud  FilePrint

Introduced in 2015
(10.2)
| Updated in 2015
(10.3)