From: ts Date: 2002-07-27T20:57:01+09:00 Subject: Re: regex: move minus sign to front for negative numbers w trailing " -" >>>>> "P" == =?iso-8859-1?Q?=22Pe=F1a=2C Botp=22?= writes: P> 99.99- 9999- 99-99 99-99- 99999.99- 9.99- It really depend on what you want : for a regexp the most difficult task is the specification. When you have a *complete* specification, then you can try to write it. For example I've added some cases pigeon% cat b.rb #!/usr/bin/ruby DATA.each do |line| puts line puts line.gsub(/(^|[^-.\d])(\d+(?:\.\d+)?)-(?=[^-.\d]|$)/,'>>\1-\2<<') puts end __END__ 99.99- 9999- 9.- .99- -99.99- 9.9-. 99-99 99-99- 99999.99- 9.99- pigeon% pigeon% b.rb 99.99- 9999- 9.- .99- -99.99- 9.9-. 99-99 99-99- 99999.99- 9.99- >>-99.99<< >> -9999<< 9.- .99- -99.99- 9.9-. 99-99 99-99- >> -99999.99<< >> -9.99<< pigeon% Guy Decoux