替换javascript中的所有事件 [英] Replace all occurances in javascript
本文介绍了替换javascript中的所有事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我搜索了不同的网站,向我展示了替换js中字符串的方法.但是实际上它不起作用!为什么?
I've searched through different websites showing me the way to replace strings in js. But actually its not working! Why?
我正在使用的代码:
var str = "This is html. This is another HTML";
str = str.replace('/html/gi','php');
输出:这是html.这是另一个html
什么都没有改变.令人沮丧!
Nothing is changing. Its Frustrating!
我使用过的参考文献:
推荐答案
无引号:
str = str.replace(/html/gi,'php');
RegExp 对象可以以其原义格式表示:
The RegExp object can be expressed in its literal format:
/I am an actual object in javascript/gi
这篇关于替换javascript中的所有事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文