Reg exp: matching relative path only.

A

Andrew Rowland

Hello. Thought I had this one cracked. Wondering if anyone can help me.

I've got a object method that cleans up image links within content by
inserting a full url to an image directory, if it does not have one already.

For example:

image.gif is replaced with http://myserver/fullpath/image.gif

http://someserver/image.gif is left alone.

Basically I'm trying to match any images that do not begin with http://

My code:

sub cleanUp{
my $self=shift;
my $content=shift;

$content=~s/src\s*=\s*\"([^h][^t][^t][^p].+?)\.(GIF|JPG|gif|jpg)?\"/src="$se
lf->{'config'}{'static'}\/$self->{'paths'}[0]\/$1.$2"/g;
return $content;
}

Doesn't seem to work. Probably an easier/better or both way of doing this.
Any takers. Hope this is clear.

Cheers

Andy R
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top