[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: perl/bash question - html link out of text



On Sun, Mar 07, 2010 at 06:07:56PM +0100, Vadkan Jozsef wrote:
> I don't know how to modify the:
> 
> sed -r 's,.*(http://[^ \"$]+).*,<a href=\"\1\">\1</a>,'
> 
> command, to not just:
> $ echo "test string http://somewhere.uk/ test" | sed -r 's,.*(http://[^
> \"$]+).*,<a href=\"\1\">\1</a>,'
> <a href="http://somewhere.uk/";>http://somewhere.uk/</a>
> 
> rather output this:
> test string <a href="http://somewhere.uk/";>http://somewhere.uk/</a> test

How about:

echo "test string http://somewhere.uk/ test" | sed -r 's,(.*)(http://[^ \"$]+).*,\1<a href=\"\2\">\2</a>,'

HTH.

Kumar
-- 
Whoa...I did a 'zcat /vmlinuz > /dev/audio' and I think I heard God...
		-- mikecd on #Linux

Attachment: signature.asc
Description: Digital signature


Reply to: