0

I am trying to remove string Quotes mark but cant able to remove.

Ex: ['moe', 'larry', 'curly'], [30, 40, 50]

Need: ['moe', 'larry', 'curly'], [30, 40, 50]

Because I'm trying Underscore Object function(_.object).

Ex: _.object("['moe', 'larry', 'curly'], [30, 40, 50]")

Only I am getting undefined result.

Ishara Madhawa
  • 3,549
  • 5
  • 24
  • 42
Ananth
  • 65
  • 3
  • 10
  • 2
    Is it just a string? `string.replace(/"/g, '')` will do it if so – StudioTime Apr 18 '18 at 12:14
  • 1
    You should learn about types first. Your question does not really make sense and you already asked a very [similar question](https://stackoverflow.com/questions/49895931/remove-square-brackets-at-beginning-and-ending-using-undersore-or-javascript). – str Apr 18 '18 at 12:15
  • 1
    Possible duplicate of [I want to remove double quotes from a String](https://stackoverflow.com/questions/19156148/i-want-to-remove-double-quotes-from-a-string) – li x Apr 18 '18 at 12:16

1 Answers1

2

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.

TessavWalstijn
  • 1,698
  • 1
  • 19
  • 36
Phillip
  • 6,033
  • 3
  • 24
  • 34
  • I trying underscore function but its not working EX: _.object(noQuotes); getting only undefined – Ananth Apr 18 '18 at 12:40
  • var quotes = "['moe', 'larry', 'curly'], [30, 40, 50]"; var noQuotes = quotes.replace(/\"/, ''); _.object(noQuotes) I am getting only "Undefined" – Ananth Apr 18 '18 at 12:52