Gavin,

> irb(main):016:0> xyz =~ /TRANDATE/               -> 48
> irb(main):017:0> xyz =~ /CHECKSUM/               -> 377
> irb(main):018:0> xyz =~ /TRANDATE.*CHECKSUM/     -> nil
> irb(main):019:0> xyz =~ /TRANDATE.*?CHECKSUM/    -> nil
> irb(main):020:0> VERSION                         -> "1.6.5"
>
> I'm sure you can all see the problem: "TRANDATE" occurs at
> position 48, and "CHECKSUM" at position 377.  Why on earth
> does (xyz =~ /TRANDATE.*CHECKSUM/) not return 48?

    Simple, the definition of /./ is "any character except a newline",
except in multiline mode where it is simply "any character".  If you look
carefully at your string, you will find three newlines ("\n") between
"TRANDATE" and "CHECKSUM".  The easy solution would be to change the regular
expression to be multiline:

xyz =~ /TRANDATE.*CHECKSUM/m   -> 48

    I hope this helps!

    - Warren Brown