views:

90

answers:

1

I do not know where my head is today, can somebody please explain to me - why I can get the hturl value by the request form and do the replace in the htstring? (I do this and it works - but only replaces one occurance of the (hturl) value.... The problem is that there is about 10 more occurances of the old value that I want to replace:

I am using Regex in conjunction with asp and javascript

<% 
htreplace = ""+Request.Form("1")+"";
hturl = Request.Form("thesite");
htstring = htreplace
htstring = htstring.replace(/,;~~~~/ig,';');
htstring = htstring.replace(hturl,'http://www.domain.net');
%>

If I change the

htstring = htstring.replace(hturl,'http://www.domain.net');

to

htstring = htstring.replace(/hturl/ig,'http://www.domain.net');

or

htstring = htstring.replace("/"+hturl+"/"+ig,'http://www.domain.net');

I cannot get the hturl value dynamically anymore ?

Anybody that can help please do! - I do not know where my head / logic is today! Thanks

+3  A: 
var myregexp = new RegExp(hturl, "ig");

htstring = htstring.replace(myregexp, 'blah');
Kaze no Koe
Thanks Kaze! - Just learned something new and it works 100% zero issues!
Gerald Ferreira
You're welcome :)
Kaze no Koe
Great help, exactly what I needed! Thanx much
TJB