這是我在做什麼正則表達式 - 保存重複捕獲
a = "%span.rockets#diamonds.ribbons.forever"
a = a.match(/(^\%\w+)([\.|\#]\w+)+/)
puts a.inspect
這是我得到
#<MatchData "%span.rockets#diamonds.ribbons.forever" 1:"%span" 2:".forever">
這就是我想要
#<MatchData "%span.rockets#diamonds.ribbons.forever" 1:"%span" 2:".rockets" 3:".#diamonds" 4:".ribbons" 5:".forever">
幫助?我嘗試和失敗:(