使用 javascript 的 Regexp.replace 中的动态值
我不知道我今天的头在哪里,有人可以向我解释一下 - 为什么我可以通过请求表单获取 hturl 值并在 htstring 中进行替换? (我这样做并且它有效 - 但只替换了一次出现的 (hturl) 值...问题是我想要替换大约 10 次旧值:
我正在将 Regex 与asp 和 javascript
<%
htreplace = ""+Request.Form("1")+"";
hturl = Request.Form("thesite");
htstring = htreplace
htstring = htstring.replace(/,;~~~~/ig,';');
htstring = htstring.replace(hturl,'http://www.example.net');
%>
如果我更改
htstring = htstring.replace(hturl,'http://www.example.net');
为
htstring = htstring.replace(/hturl/ig,'http://www.example.net');
或
htstring = htstring.replace("/"+hturl+"/"+ig,'http://www.example.net');
我无法再动态获取 hturl 值?
有人可以帮忙吗?我今天不知道我的头/逻辑在哪里,谢谢!
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.example.net');
%>
If I change the
htstring = htstring.replace(hturl,'http://www.example.net');
to
htstring = htstring.replace(/hturl/ig,'http://www.example.net');
or
htstring = htstring.replace("/"+hturl+"/"+ig,'http://www.example.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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)