Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
(その機能の 1 つとして) 文字列をスキャンして、「私は [ロボット、猿、プログラマー] で、変なにおいがする」のような「空白を埋める」ような Ruby ライブラリはありますか? そして、「私はロボットで、変なにおいがする」のような一連の完全な文を生成します。「私は猿で、変なにおいがします。」「私はプログラマーで、変なにおいがします。」
s = "I'm a [robot,monkey,programmer] and I smell funny." M = /\[.*\]/ def f x x[M][1..-2].split(',').map { |e| x.sub(M, e) } end puts f s
この要件は単純すぎて自分で実装できないと思います。既存のrubygemsを検索するよりも、自分で作成する方がはるかに高速である必要があります。