# File lib/termcolor.rb, line 39 def tag_separate(text) re = /<(\/*)([^\W_]+)(?:_(on_[^\W_]+))*(?:_with_([^\W_]+))*(?:_and_([^\W_]+))*>/ text.gsub(re) do matchs = $~.captures if matchs.shift.empty? tag = ->t{ "<#{t}>" } else matchs.reverse! tag = ->t{ "</#{t}>" } end matchs.compact.map { |word| tag[word] }.join end end