我有一個字符串:紅寶石正則表達式:掃描所有
TFS[MAD,GRO,BCN],ALC[GRO,PMI,ZAZ,MAD,BCN],BCN[ALC,...]...
我想將它轉換成一個列表:
list = (
[0] => "TFS"
[0] => "MAD"
[1] => "GRO"
[2] => "BCN"
[1] => "ALC"
[0] => "GRO"
[1] => "PMI"
[2] => "ZAZ"
[3] => "MAD"
[4] => "BCN"
[2] => "BCN"
[1] => "ALC"
[2] => ...
[3] => ...
)
如何在Ruby中做到這一點?
我嘗試:
(([A-Z]{3})\[([A-Z]{3},+))
但它在[]中只返回第一元件和不會使逗號可選的(在「]」的端部)。
哎呀......我是個慢性子。 – Nakilon 2010-10-24 13:27:11