替换“ ''用“ “在javascript中 [英] replace " ' " with " "in javascript
本文介绍了替换“ ''用“ “在javascript中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的字符串是这样的:
temp="'SE019','SR132','SC123'";
我使用的函数如下:
temp.replace("'","");
但结果将是:
SE019','SR132','SC123'
仅限第一个引用被删除我需要删除所有引号
only the first quote is removed I need all the quotes to be removed
推荐答案
使用带有 g <的正则表达式文字/ code>(对于全局,意味着匹配所有出现次数)选项。
Use a regex literal with the g
(for global, meaning match all occurrences) option.
temp.replace(/'/g,"");
参见https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp 。
这篇关于替换“ ''用“ “在javascript中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文