[js]Regexp problem

wxdqz

New Member
have a string called code and I want every foo.location.href to be removed from it.

I tried the following code, but that didn't work out. Anybody suggestions?

foo.location.href is something like: <!-- m --><a class="postlink" href="http://www.domain.com/admin/page.php?id_page=12">http://www.domain.com/admin/page.php?id_page=12</a><!-- m --> where id_page can be any number.

First attempt:
while (code.match(foo.location.href))
{
code = code.replace(foo.location.href,'');
}

Second attempt:
var url = new regExp(foo.location.href, "gi");
code = code.replace(url,'');

Third attempt:
var re2 = '/'+foo.location.href+'/gi';
code = code.replace(re2,'')

It didn't work out and all instances of foo.location.href kept in the code. What am I doing wrong?
 
Top