A new release of FormatR is out, 1.06. FormatR provides perl-like
formats for ruby plus some options the perl versions don't have like
scientific notation formats. This release introduces the ability to
read in text and an associated format and return values for the
variables used to make the given text. 

           enjoy,
             Paul

Homepage
http://www.crhc.uiuc.edu/~rubel/FormatR/

For example, if you had a format that looks like the following:
  f = <<FORMAT   
  @@ Blah @@ }Blah @< @|| @#.#'
  var_one,var_one,var_one,var_one, var_two, var_three, var_four
  @<<< @<<<      
  var_one,var_one
FORMAT

and the following variables:
  var_one, var_two, var_three, var_four = 1, 2, 3, 4.3

You could read the values in like so:
  reader = FormatReader.new (format)
  res = reader.readFormat (output)

   assert (res['var_one'] == var_one.to_s)
   assert (res['var_two'] == var_two.to_s)
   assert (res['var_three'] == var_three.to_s)
   assert (res['var_four'] == var_four)