StringExtract["string",n]
string 中の文字の n
番目のブロックを抽出する.ただし,文字のブロックとは空白文字で区切られている連なりと定義する.
StringExtract["string",{pos1,pos2,…}]
string 中のいくつかの位置からブロックを抽出する.
StringExtract["string",seppos]
sep にマッチするセパレータでブロックが区切られているとする.
StringExtract["string",pos1,pos2,…]
最低レベルは空白文字,次のレベルは改行,その上のレベルは徐々に多くなる改行数で区切って,位置 posiのブロックを抽出する.
StringExtract["string",sep1pos1,sep2pos2,…]
連続したレベルのセパレータとして sepiを使った,ブロックのネストしたリストを与える.
StringExtract
StringExtract["string",n]
string 中の文字の n
番目のブロックを抽出する.ただし,文字のブロックとは空白文字で区切られている連なりと定義する.
StringExtract["string",{pos1,pos2,…}]
string 中のいくつかの位置からブロックを抽出する.
StringExtract["string",seppos]
sep にマッチするセパレータでブロックが区切られているとする.
StringExtract["string",pos1,pos2,…]
最低レベルは空白文字,次のレベルは改行,その上のレベルは徐々に多くなる改行数で区切って,位置 posiのブロックを抽出する.
StringExtract["string",sep1pos1,sep2pos2,…]
連続したレベルのセパレータとして sepiを使った,ブロックのネストしたリストを与える.
詳細
- ブロックの位置指定は,次の任意の形を取ることができる.
-
n n 番目のブロック -n 最後から数えて n 番目のブロック {n1,n2,…} ブロックの集合 n1;;n2 n1番目から n2番目までのブロック All すべてのブロック - セパレータ sep は,実際の文字列でも文字列パターンでもよい.
例題
すべて開く すべて閉じる例 (3)
スコープ (4)
StringExtract["a bbb cccc aa d", -1]StringExtract["a bbb cccc aa d", {1, 3}]StringExtract["A tree, an apple, four pears. And more: two sacks", All]StringExtract["A tree, an apple, four pears. And more: two sacks", Except[WordCharacter].. -> All]table = "a 1
b 2
c 3 x";StringExtract[table, All, 1]StringExtract[table, 3, 1]StringExtract[table, 3, All]グループ内にない要素はMissing[…]になる:
StringExtract[table, All, 3]アプリケーション (1)
特性と関係 (4)
StringExtract["string",pattAll]はStringSplit["string",patt]に等しい:
string = "a--bbb---ccc--dddd"StringExtract[string, "--" -> All]StringSplit[string, "--"]StringExtract["string",{pos1,pos2,…}]はPart[StringSplit["string"],{pos1,pos2,…}]に等しい:
string = "a bbb cccc aa d"StringExtract[string, {1, 4, 5}]Part[StringSplit[string], {1, 4, 5}]StringExtract["string",…,pos-3,pos-2,pos-1]はStringExtract["string",…,"\n\n"pos-3,"\n"pos-2,Whitespacepos-1]に等しい:
StringExtract["a b c
d e f
g h i
j k l
m n o
p q r s
t u v
w x y z", 2, 2, 3]StringExtractをStringRiffleの出力に使うことができる:
arr = RandomInteger[9, {4, 3}];StringRiffle[arr]StringExtract[%, All, All]テキスト
Wolfram Research (2015), StringExtract, Wolfram言語関数, 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
BibTeX
@misc{reference.wolfram_2026_stringextract, author="Wolfram Research", title="{StringExtract}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/StringExtract.html}", note=[Accessed: 14-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_stringextract, organization={Wolfram Research}, title={StringExtract}, year={2015}, url={https://reference.wolfram.com/language/ref/StringExtract.html}, note=[Accessed: 14-November-2026]}