Comment detail

文字列からの情報抽出 (Nested Flatten)
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}]

Index

Feed

Other

Link

Pathtraq

loading...