From: hemant Date: 2006-11-16T04:07:22+09:00 Subject: Re: Regexp with Ruby On 11/16/06, Paul Lutus wrote: > Ajay Vijey wrote: > > > Hallo @ all, > > > > I have to replace in a File the image tags with an other! > > As another poster has pointed out, you aren't showing enough code for an > analysis, and, while you are replacing tags, please reformat your IMG tags > thus: > > > > Note the self-closing form. This won't bother older browsers, and it will > allow you to meet the newer (X)HTML standards as well. > > Here is sample program that extracts all the IMG tags from a Web page (of > both the old and new varieties): > > ---------------------------------------- > #!/usr/bin/ruby -w > > data = File.read("sample.html") > > extract = data.scan(%r{}m) > > puts extract.join("\n") > ---------------------------------------- > > This outputs from my sample page: > > > > > alt=""/> > alt=""/> > alt=""/> > > alt=""/> > > > > -- > Paul Lutus > http://www.arachnoid.com > > If i were to do this..I would use hpricot. -- There was only one Road; that it was like a great river: its springs were at every doorstep, and every path was its tributary.