文字列からの情報抽出
Posted feedbacks - Smalltalk
Squeak の Smalltalk で。正規表現は使えないので、手続き的に。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | | in delimiters candidates |
in := 'aaa abc-hidden.png>hoge-big.jpeg
---foo-hidden-small.gif|^_^a.bmp
--hiddena-hoge.png<=not hidden~~
--small.jpg<=not small(^_^)
normal-small-big.hoge'.
delimiters := in asSet reject: [:each | each isLetter or: ['-.' includes: each]].
candidates := (in findTokens: delimiters) reject: [:each | each = each sansPeriodSuffix].
World findATranscript: nil.
candidates do: [:cand |
| strm next ext size hidden |
strm := (cand findTokens: '-.') reversed readStream.
ext := strm next.
next := strm next.
(strm peek notNil and: [#(small big) includes: next])
ifTrue: [size := next. next := strm next] ifFalse: [size := 'normal'].
(hidden := strm peek notNil and: [next = #hidden])
ifTrue: [next := strm next].
Transcript cr; show: {#name->next. #ext->ext. #size->size. #hidden->hidden}]
|


にしお
#3407()
Rating0/0=0.00
サンプル入力
サンプル出力
探すべき文字列は下の条件を満たします
出力は以下の条件を満たす必要があります
このお題は、正規表現のグループに名前をつけて連想配列として取得できるPythonからの挑戦状です。
[ reply ]