On Tue, Oct 15, 2002 at 10:23:19AM +0000, martin bower wrote:
> Can anyone help me with this regex pls ?
> I'd like to split $1 into 2 parts , seperated by ':'
> 
> e.g
> 
> <LINK>www.foo.com:go here</LINK>   should be
> <A HREF="www.foo.com">go here</A>
> 
> $html =~ s/<LINK>(.*)<\/LINK>/<A HREF='$1'>$1<\/A>/gi;

You can avoid backslashes by using a different substitution delimiter,

$html =~ s~<LINK>([^:]*):(.*?)</LINK>~<a href="$1">$2</a>~gi;

I suspect you'll want http:// before that $1 if the www.foo.com is
unadorned.

It's worth getting into the habit of using lowercase for your tags, and
double quotes for your attributes. The former is mandated by XHTML, the
latter is at the very least a suggestion (you have to quote but I can't
remember if ' are valid).

Cheers,
Paul

-- 
Paul Makepeace ....................................... http://paulm.com/

"If fish were trees, then a priest will behave very oddly."
   -- http://paulm.com/toys/surrealism/

Reply via email to