Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Take a section of text specified by a number and textual unit
ResourceFunction["TextTake"][text,unit] takes the first element of type unit in text. | |
ResourceFunction["TextTake"][text,n,unit] takes the first n elements of type unit in text. | |
ResourceFunction["TextTake"][text,-n,unit] takes the last n elements of type unit in text. |
| "Paragraph" | take paragraphs of text |
| "Sentence" | take sentences of text |
| "Word" | take words of text |
| "Character" | take characters of text |
Take the first 10 words of the Gettysburg Address:
| In[1]:= |
| Out[1]= |
Take the last 10 words of the Gettysburg Address:
| In[2]:= |
| Out[2]= |
Take two sentences from a sample text:
| In[3]:= | ![]() |
| Out[3]= |
Get two paragraphs of the resource data object Lorem Ipsum:
| In[4]:= |
| Out[4]= | ![]() |
TextTake with unit set to "Character" is equivalent to StringTake and is merely included for completeness:
| In[5]:= |
| Out[5]= |
| In[6]:= |
| Out[6]= |
TextTake matches the same elements as TextCases, but returns a single String of text which also includes text found between the cases such as whitespace and punctuation:
| In[7]:= |
| In[8]:= |
| Out[8]= |
| In[9]:= |
| Out[9]= |
This work is licensed under a Creative Commons Attribution 4.0 International License