[#37762] tcltklibの作りかた — Mitsuo Igarashi <mitsu5@...>
mitsu5 です。
8 messages
2003/06/07
[#37774] Ruby/zlibのインストール方法はどのようにするのですか? — "igusa" <igusa@...>
いぐさです。
6 messages
2003/06/09
[#37801] 動的に生成したクラスメソッドのundef — Ryuichiro Hara <r@...>
動的に生成したメソッドを除く方法を知りたく質問します。
6 messages
2003/06/19
[#37814] Re: Oniguruma and PHP — kkosako@...
> スラッシュドットでも話題になっていましたが、Onigurumaを
1 message
2003/06/23
[#37815] 配列の使い方 — Kouji Miyauchi <koji.miyauchi@...>
宮内と申します。
9 messages
2003/06/23
[#37830] reference from nested class to a constant in a module included by the parent class — NISHIMATSU Takeshi <t-nissie@...>
西松と申します.
6 messages
2003/06/27
[#37838] Raccのインストールについて (MacOS X) — "Ken'ichiro Nakatani" <kenzo@...>
はじめまして。中谷と申します。
8 messages
2003/06/27
[ruby-list:37743] Re: 日本語stringの切り分け
From:
Koji Arai <JCA02266@...>
Date:
2003-06-01 04:20:25 UTC
List:
ruby-list #37743
新井です。
In message "[ruby-list:37742] 日本語stringの切り分け"
on 01 Jun 2003 12:24:08 +0900,
Yamamoto Dan <dango@ps.sakura.ne.jp> wrote:
> 団です。
>
> 下記のようにsplitLenからatrArrayを求めたいのですが
> 方法が浮かびません。よい方法はないでしょうか。
http://www.ruby-lang.org/ja/man-1.6/index.cgi?cmd=view;name=FAQ%3A%3A%C6%FC%CB%DC%B8%EC%A4%CE%BC%E8%A4%EA%B0%B7%A4%A4
の10.10 や 10.11 でいかがでしょうか?
class String
def jfold(len)
raise ArgumentError if len <= 0
ary = nil
right = self.delete("\r\n")
while right and not right.empty?
left, right = right.unpack("a#{len} a*")
if /.\z/ !~ left
right[0,0] = left[-1,1]
left[-1,1] = ''
end
if block_given?
yield left
else
ary ||= []
ary.push left
end
end
ary
end
end
str = 'aaaaaaaaああああああああaaaaaaaaaああああaaaaaaaあああ'
attrArray = []
puts str.jfold(12)
aaaaaaaaああ
ああああああ
aaaaaaaaaあ
あああaaaaaa
aあああ
--
新井康司 (Koji Arai)