readlines.each do |line| $s = $1 if /\[(.*)\]/ =~ line puts "#{$s} : #{$1} : #{$2}" if /([^ ]+) *= *([^ ]+)/ =~ lineend
[sec1] key1=val1 [sec2] key2=val2 x=y
sec1 : key1 : val1 sec2 : key2 : val2 sec2 : x : y
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!