Hi cool rubyers:

I'm sorry but my little brain is stuck w my first ruby program. The
program's objective is to move the "-" sign of negative numbers to the front
;eg, fr 999.99- to -999.99


so I run:
C:\family\ruby>ruby negatives.rb negatives.txt

and the output is:
99.99-  9999-    99-99  99-99-  99999.99-       9.99-
>>-99.99<<      >>-9999<<        >>-99<<99      >>-99<<>>-99<<
>>-99999.99<<   >>-9.99<<

My program (regex actually) works for figures even of the form 9999-999 or
99-99-. I do NOT want this since these numbers may be dates, telno, etc...
So how do I restrict my regex so that it will only process numbers of the
form 999- or 999.99- but not 999-999 or 999-99-

the file contents of negatives.rb and negatives.txt follow below.

Many thanks for the help,
-botp w small brain...


#-------------------
#negatives.txt
99.99-  9999-    99-99  99-99-  99999.99-       9.99-

#-------------------
#negatives.rb
File.open(ARGV[0]) do |f|
	f.each do |line|
		puts line
		puts (line.gsub ( /(\b)((\d+)|(\d+\.\d+))(-)/,
'>>\5\1\2<<'))
		puts
	end
end