Extracting the image url from a string

Hi,

I have a records that come from a database.

My string, wich is “{module_webapps,5007,l,1}” returns the following:

<a href="http://..." title="title"><img src="http://..." height="" width="" /></a>

All I need is the actual img src url, like:

http://...

Is there a way to pull the image url from the string with Javascript?

Thanks.

Thanks RNEL! :slight_smile:

What I want to achieve is a bit more complex I think…

To put it in context, here is my source code:

<body style="background: #010103 url({module_webapps,5007,l,1}) no-repeat fixed right top;">

When it runs on the server the output becomes:

<body style="background: #010103 url(<a href="linktossomewhere"><img src="/images/image.png" width="" height=""></a>) no-repeat fixed right top;">

What I want to achieve with jQuery is:

<body style="background: #010103 url(/images/image.png) no-repeat fixed right top;">

Btw, I’m som what of a newbie when it comes to jQuery :wink:

hi,

make the necessary changes to meet your demands, this is the basic idea


var str = "<img src=\\"http://...\\" height=\\"\\" width=\\"\\" />";
var patt = /^<img src=\\"(.*)\\" height=\\"([0-9]?)\\" width=\\"([0-9]?)\\" \\/>/g;
var result = patt.exec(str);

alert(result[1]);