这就是我正在做的
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">
帮助?我试过但失败了:(