StringExtract
StringExtract["string",n]
extracts the n block of characters in string, where blocks of characters are defined as delimited by whitespace.
StringExtract["string",{pos1,pos2,…}]
extracts blocks at several positions in string.
StringExtract["string",seppos]
takes blocks to be delimited by separators that match sep.
StringExtract["string",pos1,pos2,…]
extracts blocks at positions posi, delimiting with whitespace for the lowest level, newlines for the next level, and a successively increasing number of newlines thereafter.
StringExtract["string",sep1pos1,sep2pos2,…]
gives a nested list of blocks, with the sepi used as separators for successive levels.
Details
- The position specifications for blocks can have any of the following forms:
-
n n block -n n block counting from the end {n1,n2,…} collection of blocks n1;;n2 n1 through n2 block All all blocks - The separator sep can be a literal string or a string pattern.
Examples
open allclose allBasic Examples (3)
Scope (4)
Extract the last word from a string:
Extract the first and third words:
Extract all whitespace-delimited tokens:
Extract the English words from the text:
Take the first word from each line:
Take the first word from the third line:
Take every word from the third line:
Elements not present in a group yield Missing[…]:
Applications (1)
Properties & Relations (4)
StringExtract["string",pattAll] is equivalent to StringSplit["string",patt]:
StringExtract["string",{pos1,pos2,…}] is equivalent to Part[StringSplit["string"],{pos1,pos2,…}]:
StringExtract["string",…,pos-3,pos-2,pos-1] is equivalent to StringExtract["string",…,"\n\n"pos-3,"\n"pos-2,Whitespacepos-1]:
StringExtract can be used on the output of StringRiffle:
Text
Wolfram Research (2015), StringExtract, Wolfram Language function, https://reference.wolfram.com/language/ref/StringExtract.html.
CMS
Wolfram Language. 2015. "StringExtract." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/StringExtract.html.
APA
Wolfram Language. (2015). StringExtract. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/StringExtract.html