({{, (RefLink[StringExtract, paclet:ref/StringExtract])["string",n] 
extracts the n(^th) block of characters in string, where blocks of characters are defined as delimited by whitespace.}, {, (RefLink[StringExtract, paclet:ref/StringExtract])["string",{(Subscript[pos, 1]),(Subscript[pos, 2]),…}]
extracts blocks at several positions in string.}, {, (RefLink[StringExtract, paclet:ref/StringExtract])["string",sep->pos]
takes blocks to be delimited by separators that match sep.}, {, (RefLink[StringExtract, paclet:ref/StringExtract])["string",(Subscript[pos, 1]),(Subscript[pos, 2]),…]
extracts blocks at positions (Subscript[pos, i]), delimiting with whitespace for the lowest level, newlines for the next level, and a successively increasing number of newlines thereafter.}, {, (RefLink[StringExtract, paclet:ref/StringExtract])["string",(Subscript[sep, 1])->(Subscript[pos, 1]),(Subscript[sep, 2])->(Subscript[pos, 2]),…]
gives a nested list of blocks, with the (Subscript[sep, i]) used as separators for successive levels.}})

OpenersNotesSection(Spacer1)Details

The position specifications for blocks can have any of the following forms:

The separator sep can be a literal string or a string pattern.

OpenersPrimaryExamplesSection(Spacer1)Examples  (5)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Take the second whitespace-delimited element in a string:

StringExtract["aaa bbb ccc", 2]

Take a list of elements:

StringExtract["aaa bbb ccc", {2,3}]

Take the first two whitespace-delimited elements:

StringExtract["aaa bbb ccc", 1;;2]

Take the last whitespace-delimited element:

StringExtract["aaa bbb ccc", -1]

Take the second colon-delimited element in a string:

StringExtract["aaa:bbb:ccc",":"->2]

Give all the colon-delimited elements:

StringExtract["aaa:bbb:ccc",":"->All]

Take the first whitespace-delimited word from each line:

table="a 1
b 2
c 3 x";

StringExtract[table,All, 1]

Take the first word from the 3rd line:

StringExtract[table,3,1]

Take every word from the third line:

StringExtract[table,3,All]

Elements not present in a group yield (RefLink[Missing, paclet:ref/Missing])[…]:

StringExtract[table,All,3]

Extract the first column from a string in CSV (comma-separated values) format:

table="1,2,3
4,5,6
7,8,9";

StringExtract[table,"\n"->All,"," -> 1]

Extract all columns:

StringExtract[table,"\n"->All,"," -> All]

Extract only the first row:

StringExtract[table,"\n"->1,"," -> All]

OpenersExampleSection2(Spacer1)Properties & Relations  (1)

(RefLink[StringExtract, paclet:ref/StringExtract]) can be used on the output of (RefLink[StringRiffle, paclet:ref/StringRiffle]):

arr=RandomInteger[9,{4,3}];

StringRiffle[arr]

StringExtract[%,All,All]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[StringSplit, paclet:ref/StringSplit])  ▪  (RefLink[ImportString, paclet:ref/ImportString])  ▪  (RefLink[StringTake, paclet:ref/StringTake])  ▪  (RefLink[StringPosition, paclet:ref/StringPosition])  ▪  (RefLink[StringPartition, paclet:ref/StringPartition])  ▪  (RefLink[DelimitedSequence, paclet:ref/DelimitedSequence])  ▪  (RefLink[StringRiffle, paclet:ref/StringRiffle])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[String Operations, paclet:guide/StringOperations])}, {▪(RefLinkPlain[Text Normalization, paclet:guide/TextNormalization])}})}})