On Sat, Feb 27, 2010 at 09:12, Vadkan Jozsef <jozsi.avad...@gmail.com> wrote: > How can I do that in bash or perl, that I have a txt file, e.g.: > > $cat file.txt > Hi, this is the content of the txt file, that contains links like this: > http://www.somewhere.it/, and it could contain: http://somewhere.com, > etc.. > This is the second line, that doesn't contains links.. > .. > This is the XYZ line, that contains a link: http://www.somewhere.net > $ > > > ...ok.. so how could I make a regexp for this? > > Turning: > > http://website.org > http://www.website.org > > to this: > > <a href=http://website.org>http://website.org</a> > <a href=http://www.website.org>http://www.website.org</a> > > The solution would be: > > sed 'SOMEMAGIC' file.txt > file.html > or > perl 'SOMEBIGMAGIC' file.txt > file.html
You might look at the brand new Bleach python library: http://coffeeonthekeyboard.com/bleach-html-sanitizer-and-auto-linker-for-django-344/ That post mentions some of the problems of using a pure regex approach... of course you may know that your text file will not have any of those problems. Cheers, Kelly Clowers -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/1840f6971002270952g530d0427kc5f29a648db14...@mail.gmail.com