Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

replace " ' " with " "in javascript

My string is like this:

temp="'SE019','SR132','SC123'";

I use a function like:

temp.replace("'","");

But the result will be:

SE019','SR132','SC123'

only the first quote is removed I need all the quotes to be removed

like image 364
BaN3 Avatar asked Mar 19 '26 20:03

BaN3


1 Answers

Use a regex literal with the g (for global, meaning match all occurrences) option.

temp.replace(/'/g,"");

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp.

like image 70
Trevor Dixon Avatar answered Mar 22 '26 09:03

Trevor Dixon