[英]how to remove String Quotes in javascript
I am trying to remove string Quotes mark but cant able to remove. 我正在尝试删除字符串引号,但无法删除。
Ex: ['moe', 'larry', 'curly'], [30, 40, 50]
例如: ['moe', 'larry', 'curly'], [30, 40, 50]
Need: ['moe', 'larry', 'curly'], [30, 40, 50]
需要: ['moe', 'larry', 'curly'], [30, 40, 50]
Because I'm trying Underscore Object function(_.object). 因为我正在尝试使用下划线对象函数(_.object)。
Ex: _.object("['moe', 'larry', 'curly'], [30, 40, 50]")
例如: _.object("['moe', 'larry', 'curly'], [30, 40, 50]")
Only I am getting undefined result. 只有我得到不确定的结果。
If you just want to remove double quotes, you can do it like this: 如果只想删除双引号,则可以这样:
const quotes = "['moe', 'larry', 'curly'], [30, 40, 50]"; const noQuotes = quotes.replace(/\\"/, ''); console.log(noQuotes);
/\\"/
is a regular expression that matches any "
in the string. /\\"/
是与字符串中的任何"
匹配的正则表达式。 You simply replace them with the empty string. 您只需将它们替换为空字符串即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.