sathyz
7/29/2008 6:54:00 AM
On Jul 28, 5:42 pm, Romain LOMBARDO <touf...@gmail.com> wrote:
> Hi people,
>
> I'm trying to transform this kind of line :
> 123232321
> FOOFOOFOO
> ..
> 2431232
> BARBARBAR
>
> to
> <number>123232321</number> (actually XML)
> <number>2431232</number>
> So I have coded this script
> File.open("D:/digisoft/1b.txt","r") do |f2|
> while line = f2.gets
> f3 = line.gsub!(/\d+$/,'<number>\1</number>')
> puts f3
> end
> end
>
while line = f2.gets
print '<number>',line.to_i,'</number>',"\n" if line=~/\d/
end
- I am not sure if this is perfect solution, but this works and prints
what you expected.
Thanks,
sathyz